[#6094] Support Oracle's PARTITION BY prefixed OUTER JOIN

This commit is contained in:
lukaseder 2017-04-21 11:40:59 +02:00
parent d530495896
commit cc77a2746d
6 changed files with 924 additions and 23 deletions

View File

@ -756,6 +756,22 @@ public interface Table<R extends Record> extends TableLike<R> {
@Support
TableOnStep<Record> innerJoin(Name name);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>

View File

@ -0,0 +1,598 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;
// ...
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD;
import static org.jooq.SQLDialect.H2;
// ...
import static org.jooq.SQLDialect.HSQLDB;
// ...
// ...
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
// ...
// ...
import org.jooq.impl.DSL;
/**
* An intermediate type for the construction of a partitioned
* {@link SQLDialect#ORACLE} <code>OUTER JOIN</code> clause.
* <p>
* This step allows for adding Oracle-specific <code>PARTITION BY</code> clauses
* to the left of an <code>OUTER JOIN</code> keyword. See the Oracle
* documentation for more details here: <a href=
* "https://docs.oracle.com/database/121/SQLRF/statements_10002.htm#BABBCHJA"
* >https://docs.oracle.com/database/121/SQLRF/statements_10002.htm#BABBCHJA</a>
*
* @author Lukas Eder
*/
public interface TableOuterJoinStep<R extends Record> {
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #leftOuterJoin(TableLike)}.
*
* @see #leftOuterJoin(TableLike)
*/
@Support
TableOnStep<Record> leftJoin(TableLike<?> table);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #leftOuterJoin(String)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see #leftOuterJoin(SQL)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftJoin(SQL sql);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #leftOuterJoin(String)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see #leftOuterJoin(String)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftJoin(String sql);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #leftOuterJoin(String, Object...)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see #leftOuterJoin(String, Object...)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftJoin(String sql, Object... bindings);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #leftOuterJoin(String, QueryPart...)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see #leftOuterJoin(String, QueryPart...)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftJoin(String sql, QueryPart... parts);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #leftOuterJoin(Name)}.
*
* @see DSL#table(Name)
* @see #leftOuterJoin(Name)
*/
@Support
TableOnStep<Record> leftJoin(Name name);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
*/
@Support
TableOnStep<Record> leftOuterJoin(TableLike<?> table);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftOuterJoin(SQL sql);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftOuterJoin(String sql);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftOuterJoin(String sql, Object... bindings);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support
@PlainSQL
TableOnStep<Record> leftOuterJoin(String sql, QueryPart... parts);
/**
* <code>LEFT OUTER JOIN</code> a table to this table.
*
* @see DSL#table(Name)
* @see SQL
*/
@Support
TableOnStep<Record> leftOuterJoin(Name name);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #rightOuterJoin(TableLike)}.
* <p>
* This is only possible where the underlying RDBMS supports it.
*
* @see #rightOuterJoin(TableLike)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TableOnStep<Record> rightJoin(TableLike<?> table);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #rightOuterJoin(String)}.
* <p>
* This is only possible where the underlying RDBMS supports it.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see #rightOuterJoin(SQL)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightJoin(SQL sql);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #rightOuterJoin(String)}.
* <p>
* This is only possible where the underlying RDBMS supports it.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see #rightOuterJoin(String)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightJoin(String sql);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #rightOuterJoin(String, Object...)}.
* <p>
* This is only possible where the underlying RDBMS supports it.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see #rightOuterJoin(String, Object...)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightJoin(String sql, Object... bindings);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #rightOuterJoin(String, QueryPart...)}.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see #rightOuterJoin(String, QueryPart...)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightJoin(String sql, QueryPart... parts);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #rightOuterJoin(Name)}.
* <p>
* This is only possible where the underlying RDBMS supports it
*
* @see DSL#table(Name)
* @see #rightOuterJoin(Name)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TableOnStep<Record> rightJoin(Name name);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TableOnStep<Record> rightOuterJoin(TableLike<?> table);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightOuterJoin(SQL sql);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightOuterJoin(String sql);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightOuterJoin(String sql, Object... bindings);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
@PlainSQL
TableOnStep<Record> rightOuterJoin(String sql, QueryPart... parts);
/**
* <code>RIGHT OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
*
* @see DSL#table(Name)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TableOnStep<Record> rightOuterJoin(Name name);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #fullOuterJoin(TableLike)}.
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep<Record> fullJoin(TableLike<?> table);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #fullOuterJoin(SQL)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullJoin(SQL sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #fullOuterJoin(String)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullJoin(String sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #fullOuterJoin(String, Object...)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullJoin(String sql, Object... bindings);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #fullOuterJoin(String, QueryPart...)}.
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullJoin(String sql, QueryPart... parts);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* A synonym for {@link #fullOuterJoin(Name)}.
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep<Record> fullJoin(Name name);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep<Record> fullOuterJoin(TableLike<?> table);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(SQL)
* @see SQL
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullOuterJoin(SQL sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
* @see SQL
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullOuterJoin(String sql);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullOuterJoin(String sql, Object... bindings);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
* <p>
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
@PlainSQL
TableOnStep<Record> fullOuterJoin(String sql, QueryPart... parts);
/**
* <code>FULL OUTER JOIN</code> a table to this table.
* <p>
* This is only possible where the underlying RDBMS supports it
*
* @see DSL#table(Name)
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep<Record> fullOuterJoin(Name name);
}

View File

@ -45,9 +45,8 @@ import java.util.Collection;
* This step allows for adding Oracle-specific <code>PARTITION BY</code> clauses
* to the right of an <code>OUTER JOIN</code> keyword. See the Oracle
* documentation for more details here: <a href=
* "http://docs.oracle.com/cd/B28359_01/server.111/b28286/queries006.htm#i2054062"
* >http://docs.oracle.com/cd/B28359_01/server.111/b28286/queries006.htm#
* i2054062</a>
* "https://docs.oracle.com/database/121/SQLRF/statements_10002.htm#BABBCHJA"
* >https://docs.oracle.com/database/121/SQLRF/statements_10002.htm#BABBCHJA</a>
*
* @author Lukas Eder
*/

View File

@ -89,6 +89,7 @@ import org.jooq.TableField;
import org.jooq.TableLike;
import org.jooq.TableOnStep;
import org.jooq.TableOptionalOnStep;
import org.jooq.TableOuterJoinStep;
import org.jooq.TablePartitionByStep;
import org.jooq.UniqueKey;
// ...
@ -928,6 +929,18 @@ abstract class AbstractTable<R extends Record> extends AbstractQueryPart impleme
return innerJoin(table(name));
}
@Override
public final TablePartitionByStep<Record> leftJoin(TableLike<?> table) {
return leftOuterJoin(table);

View File

@ -91,6 +91,7 @@ import static org.jooq.impl.Tools.DataKey.DATA_COLLECT_SEMI_ANTI_JOIN;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.jooq.Clause;
@ -110,8 +111,8 @@ import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableLike;
import org.jooq.TableOnConditionStep;
import org.jooq.TableOnStep;
import org.jooq.TableOptionalOnStep;
import org.jooq.TableOuterJoinStep;
import org.jooq.exception.DataAccessException;
/**
@ -119,7 +120,11 @@ import org.jooq.exception.DataAccessException;
*
* @author Lukas Eder
*/
final class JoinTable extends AbstractTable<Record> implements TableOptionalOnStep<Record>, TableOnConditionStep<Record> {
final class JoinTable extends AbstractTable<Record>
implements
TableOuterJoinStep<Record>,
TableOptionalOnStep<Record>,
TableOnConditionStep<Record> {
/**
* Generated UID
@ -129,18 +134,32 @@ final class JoinTable extends AbstractTable<Record> implements TableOptionalOnSt
private final Table<?> lhs;
private final Table<?> rhs;
private final QueryPartList<Field<?>> rhsPartitionBy;
private final JoinType type;
private final ConditionProviderImpl condition;
private final QueryPartList<Field<?>> using;
JoinTable(TableLike<?> lhs, TableLike<?> rhs, JoinType type) {
super("join");
this.lhs = lhs.asTable();
this.rhs = rhs.asTable();
this.rhsPartitionBy = new QueryPartList<Field<?>>();
this.type = type;
this.condition = new ConditionProviderImpl();
@ -169,13 +188,10 @@ final class JoinTable extends AbstractTable<Record> implements TableOptionalOnSt
Keyword keyword = translatedType.toKeyword();
if (translatedType == CROSS_APPLY && ctx.family() == POSTGRES) {
if (translatedType == CROSS_APPLY && ctx.family() == POSTGRES)
keyword = K_CROSS_JOIN_LATERAL;
}
else if (translatedType == OUTER_APPLY && ctx.family() == POSTGRES) {
else if (translatedType == OUTER_APPLY && ctx.family() == POSTGRES)
keyword = K_LEFT_OUTER_JOIN_LATERAL;
}
@ -185,6 +201,18 @@ final class JoinTable extends AbstractTable<Record> implements TableOptionalOnSt
toSQLTable(ctx, lhs);
switch (translatedType) {
case LEFT_SEMI_JOIN:
case LEFT_ANTI_JOIN:
@ -220,17 +248,18 @@ final class JoinTable extends AbstractTable<Record> implements TableOptionalOnSt
toSQLTable(ctx, rhs);
// [#1645] The Oracle PARTITION BY clause can be put to the right of an
// OUTER JOINed table
if (!rhsPartitionBy.isEmpty()) {
ctx.formatSeparator()
.start(TABLE_JOIN_PARTITION_BY)
.visit(K_PARTITION_BY)
.sql(" (")
.visit(rhsPartitionBy)
.sql(')')
.end(TABLE_JOIN_PARTITION_BY);
}
// CROSS JOIN and NATURAL JOIN do not have any condition clauses
if (!asList(CROSS_JOIN,

View File

@ -0,0 +1,246 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import static org.jooq.JoinType.FULL_OUTER_JOIN;
import static org.jooq.JoinType.LEFT_OUTER_JOIN;
import static org.jooq.JoinType.RIGHT_OUTER_JOIN;
import static org.jooq.impl.DSL.table;
import java.util.Collection;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.SQL;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.TableOnStep;
import org.jooq.TableOuterJoinStep;
/**
* @author Lukas Eder
*/
final class PartitionJoinTable implements TableOuterJoinStep<Record> {
private final Table<?> lhs;
private final Collection<? extends Field<?>> lhsPartitionBy;
PartitionJoinTable(Table<?> lhs, Collection<? extends Field<?>> lhsPartitionBy) {
this.lhs = lhs;
this.lhsPartitionBy = lhsPartitionBy;
}
@Override
public final TableOnStep<Record> leftJoin(TableLike<?> table) {
return leftOuterJoin(table);
}
@Override
public final TableOnStep<Record> leftJoin(SQL sql) {
return leftOuterJoin(sql);
}
@Override
public final TableOnStep<Record> leftJoin(String sql) {
return leftOuterJoin(sql);
}
@Override
public final TableOnStep<Record> leftJoin(String sql, Object... bindings) {
return leftOuterJoin(sql, bindings);
}
@Override
public final TableOnStep<Record> leftJoin(String sql, QueryPart... parts) {
return leftOuterJoin(sql, parts);
}
@Override
public final TableOnStep<Record> leftJoin(Name name) {
return leftOuterJoin(name);
}
@Override
public final TableOnStep<Record> leftOuterJoin(TableLike<?> table) {
return new JoinTable(lhs, table, LEFT_OUTER_JOIN, lhsPartitionBy);
}
@Override
public final TableOnStep<Record> leftOuterJoin(SQL sql) {
return leftOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> leftOuterJoin(String sql) {
return leftOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> leftOuterJoin(String sql, Object... bindings) {
return leftOuterJoin(table(sql, bindings));
}
@Override
public final TableOnStep<Record> leftOuterJoin(String sql, QueryPart... parts) {
return leftOuterJoin(table(sql, parts));
}
@Override
public final TableOnStep<Record> leftOuterJoin(Name name) {
return leftOuterJoin(table(name));
}
@Override
public final TableOnStep<Record> rightJoin(TableLike<?> table) {
return rightOuterJoin(table);
}
@Override
public final TableOnStep<Record> rightJoin(SQL sql) {
return rightOuterJoin(sql);
}
@Override
public final TableOnStep<Record> rightJoin(String sql) {
return rightOuterJoin(sql);
}
@Override
public final TableOnStep<Record> rightJoin(String sql, Object... bindings) {
return rightOuterJoin(sql, bindings);
}
@Override
public final TableOnStep<Record> rightJoin(String sql, QueryPart... parts) {
return rightOuterJoin(sql, parts);
}
@Override
public final TableOnStep<Record> rightJoin(Name name) {
return rightOuterJoin(name);
}
@Override
public final TableOnStep<Record> rightOuterJoin(TableLike<?> table) {
return new JoinTable(lhs, table, RIGHT_OUTER_JOIN, lhsPartitionBy);
}
@Override
public final TableOnStep<Record> rightOuterJoin(SQL sql) {
return rightOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> rightOuterJoin(String sql) {
return rightOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> rightOuterJoin(String sql, Object... bindings) {
return rightOuterJoin(table(sql, bindings));
}
@Override
public final TableOnStep<Record> rightOuterJoin(String sql, QueryPart... parts) {
return rightOuterJoin(table(sql, parts));
}
@Override
public final TableOnStep<Record> rightOuterJoin(Name name) {
return rightOuterJoin(table(name));
}
@Override
public final TableOnStep<Record> fullJoin(TableLike<?> table) {
return fullOuterJoin(table);
}
@Override
public final TableOnStep<Record> fullJoin(SQL sql) {
return fullOuterJoin(sql);
}
@Override
public final TableOnStep<Record> fullJoin(String sql) {
return fullOuterJoin(sql);
}
@Override
public final TableOnStep<Record> fullJoin(String sql, Object... bindings) {
return fullOuterJoin(sql, bindings);
}
@Override
public final TableOnStep<Record> fullJoin(String sql, QueryPart... parts) {
return fullOuterJoin(sql, parts);
}
@Override
public final TableOnStep<Record> fullJoin(Name name) {
return fullOuterJoin(name);
}
@Override
public final TableOnStep<Record> fullOuterJoin(TableLike<?> table) {
return new JoinTable(lhs, table, FULL_OUTER_JOIN, lhsPartitionBy);
}
@Override
public final TableOnStep<Record> fullOuterJoin(SQL sql) {
return fullOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> fullOuterJoin(String sql) {
return fullOuterJoin(table(sql));
}
@Override
public final TableOnStep<Record> fullOuterJoin(String sql, Object... bindings) {
return fullOuterJoin(table(sql, bindings));
}
@Override
public final TableOnStep<Record> fullOuterJoin(String sql, QueryPart... parts) {
return fullOuterJoin(table(sql, parts));
}
@Override
public final TableOnStep<Record> fullOuterJoin(Name name) {
return fullOuterJoin(table(name));
}
}