[#4825] Add support for Oracle table-valued functions - Aliasing not working yet

This commit is contained in:
lukaseder 2015-12-21 08:22:35 +01:00
parent 7c312199ff
commit 2de54263ff
2 changed files with 37 additions and 18 deletions

View File

@ -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<Q extends QueryPart> extends AbstractQueryPart {
&& asList(CUBRID, FIREBIRD).contains(family)
&& (wrapped instanceof TableImpl || wrapped instanceof CommonTableExpressionImpl)) {
@SuppressWarnings("unchecked")
Select<Record> select =
select(list(field("*"))).from(((Table<?>) wrapped).as(alias));

View File

@ -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<R extends Record> extends AbstractTable<R> {
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<Field<?>>(parameters));
else
ctx.sql('(')
.visit(new QueryPartList<Field<?>>(parameters))
.sql(')');
}
// [#2925] Some dialects don't like empty parameter lists
if (ctx.family() == FIREBIRD && parameters.length == 0)
ctx.visit(new QueryPartList<Field<?>>(parameters));
else
ctx.sql('(')
.visit(new QueryPartList<Field<?>>(parameters))
.sql(')');
}
}