[#1139] Add support for Postgres TABLE types - Added test function

This commit is contained in:
Lukas Eder 2013-02-16 09:44:26 +01:00
parent e958dc2908
commit 23cc627740
4 changed files with 152 additions and 4 deletions

View File

@ -36,6 +36,7 @@
package org.jooq.test;
import static org.jooq.test.postgres.generatedclasses.Routines.fSearchBook;
import static org.jooq.test.postgres.generatedclasses.Tables.T_639_NUMBERS_TABLE;
import static org.jooq.test.postgres.generatedclasses.Tables.T_725_LOB_TEST;
import static org.jooq.test.postgres.generatedclasses.Tables.T_785;
@ -840,4 +841,16 @@ public class PostgresTest extends jOOQAbstractTest<
.fetchOne(0));
}
@Test
public void testPostgresTableFunction() throws Exception {
// TODO [#1139] Further elaborate this test
create().select().from(fSearchBook("Animal", 1L, 0L).toString()).fetch();
System.out.println(create().select(fSearchBook("Animal", 1L, 0L)).fetch());
// This doesn't work, as jOOQ doesn't know how to correctly register
// OUT parameters for the returned cursor
// Object result = Routines.fSearchBook(create(), "Animal", 1L, 0L);
}
}

View File

@ -26,6 +26,7 @@ DROP FUNCTION f317(p1 int, p2 int, p3 int, p4 int);/
DROP FUNCTION p_get_two_cursors(books OUT refcursor, authors OUT refcursor)/
DROP FUNCTION p_get_one_cursor(total OUT int, books OUT refcursor, book_ids in int[])/
DROP FUNCTION f_get_one_cursor(book_ids IN int[])/
DROP FUNCTION f_search_book(p_title character varying, p_limit bigint, p_offset bigint)/
DROP TRIGGER IF EXISTS t_triggers_trigger ON t_triggers/
DROP FUNCTION p_triggers()/
@ -449,6 +450,16 @@ CREATE VIEW v_book AS
SELECT * FROM t_book
/
CREATE OR REPLACE FUNCTION f_search_book(p_title character varying, p_limit bigint, p_offset bigint)
RETURNS SETOF t_book AS
$BODY$
SELECT * FROM t_book
WHERE (LOWER(title) LIKE LOWER('%' || p_title || '%'))
LIMIT p_limit OFFSET p_offset;
$BODY$
LANGUAGE sql VOLATILE
COST 100
ROWS 1000;
CREATE FUNCTION p_unused (in1 VARCHAR, out1 OUT INT, out2 IN OUT INT)
AS $$

View File

@ -216,6 +216,43 @@ public final class Routines {
return f.asField();
}
/**
* Call <code>public.f_search_book</code>
*/
public static java.lang.Object fSearchBook(org.jooq.Configuration configuration, java.lang.String pTitle, java.lang.Long pLimit, java.lang.Long pOffset) {
org.jooq.test.postgres.generatedclasses.routines.FSearchBook f = new org.jooq.test.postgres.generatedclasses.routines.FSearchBook();
f.setPTitle(pTitle);
f.setPLimit(pLimit);
f.setPOffset(pOffset);
f.execute(configuration);
return f.getReturnValue();
}
/**
* Get <code>public.f_search_book</code> as a field
*/
public static org.jooq.Field<java.lang.Object> fSearchBook(java.lang.String pTitle, java.lang.Long pLimit, java.lang.Long pOffset) {
org.jooq.test.postgres.generatedclasses.routines.FSearchBook f = new org.jooq.test.postgres.generatedclasses.routines.FSearchBook();
f.setPTitle(pTitle);
f.setPLimit(pLimit);
f.setPOffset(pOffset);
return f.asField();
}
/**
* Get <code>public.f_search_book</code> as a field
*/
public static org.jooq.Field<java.lang.Object> fSearchBook(org.jooq.Field<java.lang.String> pTitle, org.jooq.Field<java.lang.Long> pLimit, org.jooq.Field<java.lang.Long> pOffset) {
org.jooq.test.postgres.generatedclasses.routines.FSearchBook f = new org.jooq.test.postgres.generatedclasses.routines.FSearchBook();
f.setPTitle(pTitle);
f.setPLimit(pLimit);
f.setPOffset(pOffset);
return f.asField();
}
/**
* Call <code>public.f317</code>
*/
@ -259,8 +296,8 @@ public final class Routines {
/**
* Call <code>public.p_arrays</code>
*/
public static java.lang.Long[] pArrays2(org.jooq.Configuration configuration, java.lang.Long[] inArray) {
org.jooq.test.postgres.generatedclasses.routines.PArrays2 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays2();
public static java.lang.String[] pArrays3(org.jooq.Configuration configuration, java.lang.String[] inArray) {
org.jooq.test.postgres.generatedclasses.routines.PArrays3 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays3();
p.setInArray(inArray);
p.execute(configuration);
@ -281,8 +318,8 @@ public final class Routines {
/**
* Call <code>public.p_arrays</code>
*/
public static java.lang.String[] pArrays3(org.jooq.Configuration configuration, java.lang.String[] inArray) {
org.jooq.test.postgres.generatedclasses.routines.PArrays3 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays3();
public static java.lang.Long[] pArrays2(org.jooq.Configuration configuration, java.lang.Long[] inArray) {
org.jooq.test.postgres.generatedclasses.routines.PArrays2 p = new org.jooq.test.postgres.generatedclasses.routines.PArrays2();
p.setInArray(inArray);
p.execute(configuration);

View File

@ -0,0 +1,87 @@
/**
* This class is generated by jOOQ
*/
package org.jooq.test.postgres.generatedclasses.routines;
/**
* This class is generated by jOOQ.
*/
@java.lang.SuppressWarnings("all")
public class FSearchBook extends org.jooq.impl.AbstractRoutine<java.lang.Object> {
private static final long serialVersionUID = 1182854928;
/**
* The parameter <code>public.f_search_book.RETURN_VALUE</code>.
*/
public static final org.jooq.Parameter<java.lang.Object> RETURN_VALUE = createParameter("RETURN_VALUE", org.jooq.impl.DefaultDataType.getDefaultDataType("USER-DEFINED"));
/**
* The parameter <code>public.f_search_book.p_title</code>.
*/
public static final org.jooq.Parameter<java.lang.String> P_TITLE = createParameter("p_title", org.jooq.impl.SQLDataType.VARCHAR);
/**
* The parameter <code>public.f_search_book.p_limit</code>.
*/
public static final org.jooq.Parameter<java.lang.Long> P_LIMIT = createParameter("p_limit", org.jooq.impl.SQLDataType.BIGINT);
/**
* The parameter <code>public.f_search_book.p_offset</code>.
*/
public static final org.jooq.Parameter<java.lang.Long> P_OFFSET = createParameter("p_offset", org.jooq.impl.SQLDataType.BIGINT);
/**
* Create a new routine call instance
*/
public FSearchBook() {
super("f_search_book", org.jooq.test.postgres.generatedclasses.Public.PUBLIC, org.jooq.impl.DefaultDataType.getDefaultDataType("USER-DEFINED"));
setReturnParameter(RETURN_VALUE);
addInParameter(P_TITLE);
addInParameter(P_LIMIT);
addInParameter(P_OFFSET);
}
/**
* Set the <code>p_title</code> parameter IN value to the routine
*/
public void setPTitle(java.lang.String value) {
setValue(org.jooq.test.postgres.generatedclasses.routines.FSearchBook.P_TITLE, value);
}
/**
* Set the <code>p_title</code> parameter to the function to be used with a {@link org.jooq.Select} statement
*/
public void setPTitle(org.jooq.Field<java.lang.String> field) {
setField(P_TITLE, field);
}
/**
* Set the <code>p_limit</code> parameter IN value to the routine
*/
public void setPLimit(java.lang.Long value) {
setValue(org.jooq.test.postgres.generatedclasses.routines.FSearchBook.P_LIMIT, value);
}
/**
* Set the <code>p_limit</code> parameter to the function to be used with a {@link org.jooq.Select} statement
*/
public void setPLimit(org.jooq.Field<java.lang.Long> field) {
setField(P_LIMIT, field);
}
/**
* Set the <code>p_offset</code> parameter IN value to the routine
*/
public void setPOffset(java.lang.Long value) {
setValue(org.jooq.test.postgres.generatedclasses.routines.FSearchBook.P_OFFSET, value);
}
/**
* Set the <code>p_offset</code> parameter to the function to be used with a {@link org.jooq.Select} statement
*/
public void setPOffset(org.jooq.Field<java.lang.Long> field) {
setField(P_OFFSET, field);
}
}