From 2de54263ff28ed23d6fe1ad0c25d40695e9aacc2 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Mon, 21 Dec 2015 08:22:35 +0100 Subject: [PATCH] [#4825] Add support for Oracle table-valued functions - Aliasing not working yet --- jOOQ/src/main/java/org/jooq/impl/Alias.java | 3 +- .../main/java/org/jooq/impl/TableImpl.java | 52 +++++++++++++------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/Alias.java b/jOOQ/src/main/java/org/jooq/impl/Alias.java index 1624cb7ed3..9a8be3d4e0 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Alias.java +++ b/jOOQ/src/main/java/org/jooq/impl/Alias.java @@ -68,8 +68,8 @@ import static org.jooq.SQLDialect.SQLITE; import static org.jooq.impl.DSL.falseCondition; import static org.jooq.impl.DSL.field; import static org.jooq.impl.DSL.select; -import static org.jooq.impl.Utils.DataKey.DATA_UNALIAS_ALIASES_IN_ORDER_BY; import static org.jooq.impl.Utils.list; +import static org.jooq.impl.Utils.DataKey.DATA_UNALIAS_ALIASES_IN_ORDER_BY; import org.jooq.Clause; import org.jooq.Context; @@ -132,7 +132,6 @@ class Alias extends AbstractQueryPart { && asList(CUBRID, FIREBIRD).contains(family) && (wrapped instanceof TableImpl || wrapped instanceof CommonTableExpressionImpl)) { - @SuppressWarnings("unchecked") Select select = select(list(field("*"))).from(((Table) wrapped).as(alias)); diff --git a/jOOQ/src/main/java/org/jooq/impl/TableImpl.java b/jOOQ/src/main/java/org/jooq/impl/TableImpl.java index fd2b27bee3..1455076a9e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/TableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/TableImpl.java @@ -41,10 +41,12 @@ package org.jooq.impl; +import static java.util.Arrays.asList; import static org.jooq.Clause.TABLE; import static org.jooq.Clause.TABLE_ALIAS; import static org.jooq.Clause.TABLE_REFERENCE; import static org.jooq.SQLDialect.FIREBIRD; +// ... import static org.jooq.SQLDialect.POSTGRES; import java.util.Arrays; @@ -133,27 +135,45 @@ public class TableImpl extends AbstractTable { alias.accept(ctx); } else { - if (ctx.qualify() && (ctx.family() != POSTGRES || parameters == null || ctx.declareTables())) { - Schema mappedSchema = Utils.getMappedSchema(ctx.configuration(), getSchema()); + /* [pro] xx + xx xxxxxxxxxxxxx xx xxxxxx xx xxxxxxxxxx xx xxxx xx xxxxxxxxxxxxxxxxxxxx x + xxxxxxxxxxxxxxxxxxxx + xxxxxxxxxx - if (mappedSchema != null) { - ctx.visit(mappedSchema); - ctx.sql('.'); - } + xxxxxxxxxxxxx + + xx xxxxxxx xxxx xxxxxxxx xxxxx xxxx xx xxxxxxx xx xx xx + xxxxxxxxxx xx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx + x + xxxx + xx [/pro] */ + accept0(ctx); + } + } + + private void accept0(Context ctx) { + if (ctx.qualify() && + (!asList(POSTGRES).contains(ctx.family()) || parameters == null || ctx.declareTables())) { + Schema mappedSchema = Utils.getMappedSchema(ctx.configuration(), getSchema()); + + if (mappedSchema != null) { + ctx.visit(mappedSchema); + ctx.sql('.'); } + } - ctx.literal(Utils.getMappedTable(ctx.configuration(), this).getName()); + ctx.literal(Utils.getMappedTable(ctx.configuration(), this).getName()); - if (parameters != null && ctx.declareTables()) { + if (parameters != null && ctx.declareTables()) { - // [#2925] Some dialects don't like empty parameter lists - if (ctx.family() == FIREBIRD && parameters.length == 0) - ctx.visit(new QueryPartList>(parameters)); - else - ctx.sql('(') - .visit(new QueryPartList>(parameters)) - .sql(')'); - } + // [#2925] Some dialects don't like empty parameter lists + if (ctx.family() == FIREBIRD && parameters.length == 0) + ctx.visit(new QueryPartList>(parameters)); + else + ctx.sql('(') + .visit(new QueryPartList>(parameters)) + .sql(')'); } }