[#1256] User defined H2 functions codegen bug

This commit is contained in:
Lukas Eder 2012-04-01 07:51:18 +00:00
parent 52039b4b0c
commit c105db24ff
5 changed files with 96 additions and 0 deletions

View File

@ -244,6 +244,9 @@ public class H2Database extends AbstractDatabase {
.from(FUNCTION_ALIASES)
.leftOuterJoin(TYPE_INFO)
.on(FunctionAliases.DATA_TYPE.equal(TypeInfo.DATA_TYPE))
// [#1256] TODO implement this correctly. Not sure if POS = 0
// is the right predicate to rule out duplicate entries in TYPE_INFO
.and(TypeInfo.POS.equal(0))
.where(FunctionAliases.ALIAS_SCHEMA.in(getInputSchemata()))
.and(FunctionAliases.RETURNS_RESULT.in((short) 1, (short) 2))
.orderBy(FunctionAliases.ALIAS_NAME).fetch()) {

View File

@ -124,6 +124,10 @@ public class F {
return 1000 * p1 + 100 * p2 + p4;
}
public static String f1256(String string) {
return string;
}
public static Integer fNumber(Integer n) {
return n;
}

View File

@ -9,6 +9,7 @@ DROP ALIAS IF EXISTS f_author_exists/
DROP ALIAS IF EXISTS f_one/
DROP ALIAS IF EXISTS f_number/
DROP ALIAS IF EXISTS f317/
DROP ALIAS IF EXISTS f1256/
DROP ALIAS IF EXISTS p_create_author/
DROP ALIAS IF EXISTS p_create_author_by_name/
DROP ALIAS IF EXISTS f_get_one_cursor/
@ -384,6 +385,7 @@ SELECT * FROM t_book
CREATE ALIAS f_one FOR "org.jooq.test.h2.F.fOne";/
CREATE ALIAS f_number FOR "org.jooq.test.h2.F.fNumber";/
CREATE ALIAS f317 FOR "org.jooq.test.h2.F.f317";/
CREATE ALIAS f1256 FOR "org.jooq.test.h2.F.f1256";/
CREATE ALIAS f_arrays1 FOR "org.jooq.test.h2.F.f_arrays1";/
CREATE ALIAS f_arrays2 FOR "org.jooq.test.h2.F.f_arrays2";/
CREATE ALIAS f_arrays3 FOR "org.jooq.test.h2.F.f_arrays3";/

View File

@ -10,6 +10,44 @@ package org.jooq.test.h2.generatedclasses;
*/
public final class Routines {
/**
* Call PUBLIC.F1256
*
* @param p1
* @throws org.jooq.exception.DataAccessException if something went wrong executing the query
*/
public static java.lang.String f1256(org.jooq.Configuration configuration, java.lang.String p1) {
org.jooq.test.h2.generatedclasses.routines.F1256 f = new org.jooq.test.h2.generatedclasses.routines.F1256();
f.setP1(p1);
f.execute(configuration);
return f.getReturnValue();
}
/**
* Get PUBLIC.F1256 as a field
*
* @param p1
*/
public static org.jooq.Field<java.lang.String> f1256(java.lang.String p1) {
org.jooq.test.h2.generatedclasses.routines.F1256 f = new org.jooq.test.h2.generatedclasses.routines.F1256();
f.setP1(p1);
return f.asField();
}
/**
* Get PUBLIC.F1256 as a field
*
* @param p1
*/
public static org.jooq.Field<java.lang.String> f1256(org.jooq.Field<java.lang.String> p1) {
org.jooq.test.h2.generatedclasses.routines.F1256 f = new org.jooq.test.h2.generatedclasses.routines.F1256();
f.setP1(p1);
return f.asField();
}
/**
* Call PUBLIC.F317
*

View File

@ -0,0 +1,49 @@
/**
* This class is generated by jOOQ
*/
package org.jooq.test.h2.generatedclasses.routines;
/**
* This class is generated by jOOQ.
*/
public class F1256 extends org.jooq.impl.AbstractRoutine<java.lang.String> {
private static final long serialVersionUID = 588776449;
/**
* An uncommented item
*/
public static final org.jooq.Parameter<java.lang.String> RETURN_VALUE = createParameter("RETURN_VALUE", org.jooq.impl.SQLDataType.VARCHAR);
/**
* An uncommented item
*/
public static final org.jooq.Parameter<java.lang.String> P1 = createParameter("P1", org.jooq.impl.SQLDataType.VARCHAR);
/**
* Create a new routine call instance
*/
public F1256() {
super("F1256", org.jooq.test.h2.generatedclasses.Public.PUBLIC, org.jooq.impl.SQLDataType.VARCHAR);
setReturnParameter(RETURN_VALUE);
addInParameter(P1);
}
/**
* Set the <code>P1</code> parameter to the routine
*/
public void setP1(java.lang.String value) {
setValue(P1, value);
}
/**
* Set the <code>P1</code> parameter to the function
* <p>
* Use this method only, if the function is called as a {@link org.jooq.Field} in a {@link org.jooq.Select} statement!
*/
public void setP1(org.jooq.Field<java.lang.String> field) {
setField(P1, field);
}
}