[jOOQ/jOOQ#10354] Retrofit Table.where() implementation to use new InlineDerivedTable

This commit is contained in:
Lukas Eder 2020-07-03 14:19:12 +02:00
parent 61b16c5740
commit 2787cefe07
2 changed files with 12 additions and 14 deletions

View File

@ -52,11 +52,11 @@ import static org.jooq.JoinType.NATURAL_RIGHT_OUTER_JOIN;
import static org.jooq.JoinType.OUTER_APPLY;
import static org.jooq.JoinType.RIGHT_OUTER_JOIN;
import static org.jooq.JoinType.STRAIGHT_JOIN;
import static org.jooq.impl.DSL.and;
import static org.jooq.impl.DSL.condition;
import static org.jooq.impl.DSL.exists;
// ...
import static org.jooq.impl.DSL.notExists;
import static org.jooq.impl.DSL.selectFrom;
import static org.jooq.impl.DSL.sql;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.DSL.val;
@ -1110,17 +1110,17 @@ abstract class AbstractTable<R extends Record> extends AbstractNamed implements
@Override
public /* non-final */ Table<R> where(Condition condition) {
return selectFrom(this).where(condition).asTable(this);
return new InlineDerivedTable<>(this, condition);
}
@Override
public /* non-final */ Table<R> where(Condition... conditions) {
return selectFrom(this).where(conditions).asTable(this);
return where(and(conditions));
}
@Override
public /* non-final */ Table<R> where(Collection<? extends Condition> conditions) {
return selectFrom(this).where(conditions).asTable(this);
return where(and(conditions));
}
@Override

View File

@ -2882,21 +2882,19 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
}
final ConditionProviderImpl getWhere() {
// Do not apply SEEK predicates in the WHERE clause, if:
// - There is no ORDER BY clause (SEEK is non-deterministic)
// - There is no SEEK clause (obvious case)
// - There are unions (union is nested in derived table
// and SEEK predicate is applied outside). See [#7459]
if (getOrderBy().isEmpty() || getSeek().isEmpty() || unionOp.size() > 0)
return condition;
ConditionProviderImpl result = new ConditionProviderImpl();
if (condition.hasWhere())
result.addConditions(condition.getWhere());
result.addConditions(getSeekCondition());
// Apply SEEK predicates in the WHERE clause only if:
// - There is an ORDER BY clause (SEEK is non-deterministic)
// - There is a SEEK clause (obvious case)
// - There are no unions (union is nested in derived table
// and SEEK predicate is applied outside). See [#7459]
if (!getOrderBy().isEmpty() && !getSeek().isEmpty() && unionOp.isEmpty())
result.addConditions(getSeekCondition());
return result;
}