[jOOQ/jOOQ#15448] SEEK clause has no effect if used in the first set
operation subquery
This commit is contained in:
parent
ded36561ea
commit
0218afa4e4
@ -2891,7 +2891,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
context.formatSeparator()
|
||||
.visit(K_WHERE)
|
||||
.sql(' ')
|
||||
.qualify(false, c -> c.visit(getSeekCondition(context)));
|
||||
.qualify(false, c -> c.visit(getSeekCondition(context, false)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3688,7 +3688,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
}
|
||||
|
||||
private final boolean applySeekOnDerivedTable() {
|
||||
return !getSeek().isEmpty() && !getOrderBy().isEmpty() && !unionOp.isEmpty();
|
||||
return !getSeek(false).isEmpty() && !getOrderBy(false).isEmpty() && !unionOp.isEmpty();
|
||||
}
|
||||
|
||||
private final boolean wrapQueryExpressionBodyInDerivedTable(Context<?> ctx, boolean hasAlternativeFields) {
|
||||
@ -4594,8 +4594,8 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
// - There are no unions (union is nested in derived table
|
||||
// and SEEK predicate is applied outside). See [#7459]
|
||||
// [#15820] We're not grouping
|
||||
if (!isGrouping() && !getOrderBy().isEmpty() && !getSeek().isEmpty() && unionOp.isEmpty())
|
||||
where0.addConditions(getSeekCondition(ctx));
|
||||
if (!isGrouping() && !getOrderBy(true).isEmpty() && !getSeek(true).isEmpty())
|
||||
where0.addConditions(getSeekCondition(ctx, true));
|
||||
|
||||
addPathConditions(ctx, where0, tablelist);
|
||||
|
||||
@ -4660,10 +4660,10 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final Condition getSeekCondition(Context<?> ctx) {
|
||||
SortFieldList o = getOrderBy();
|
||||
final Condition getSeekCondition(Context<?> ctx, boolean localSeek) {
|
||||
SortFieldList o = getOrderBy(localSeek);
|
||||
Condition c = null;
|
||||
QueryPartList<Field<?>> s = getSeek();
|
||||
QueryPartList<Field<?>> s = getSeek(localSeek);
|
||||
|
||||
// If we have uniform sorting, more efficient row value expression
|
||||
// predicates can be applied, which can be optimised in some databases.
|
||||
@ -4821,8 +4821,8 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
// - There are no unions (union is nested in derived table
|
||||
// and SEEK predicate is applied outside). See [#7459]
|
||||
// [#15820] We're not grouping
|
||||
if (isGrouping() && !getOrderBy().isEmpty() && !getSeek().isEmpty() && unionOp.isEmpty())
|
||||
result.addConditions(getSeekCondition(ctx));
|
||||
if (isGrouping() && !getOrderBy(true).isEmpty() && !getSeek(true).isEmpty())
|
||||
result.addConditions(getSeekCondition(ctx, true));
|
||||
|
||||
if (NO_SUPPORT_LIMIT_ZERO.contains(ctx.dialect()) && limit.limitZero() && isGrouping())
|
||||
result.addConditions(falseCondition());
|
||||
@ -4835,11 +4835,19 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
}
|
||||
|
||||
final SortFieldList getOrderBy() {
|
||||
return (unionOp.size() == 0) ? orderBy : unionOrderBy;
|
||||
return getOrderBy(unionOp.size() == 0);
|
||||
}
|
||||
|
||||
final SortFieldList getOrderBy(boolean localOrderBy) {
|
||||
return localOrderBy ? orderBy : unionOrderBy;
|
||||
}
|
||||
|
||||
final QueryPartList<Field<?>> getSeek() {
|
||||
return (unionOp.size() == 0) ? seek : unionSeek;
|
||||
return getSeek(unionOp.size() == 0);
|
||||
}
|
||||
|
||||
final QueryPartList<Field<?>> getSeek(boolean localSeek) {
|
||||
return localSeek ? seek : unionSeek;
|
||||
}
|
||||
|
||||
final Limit getLimit() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user