[#8293] Wrong Javadoc on SelectQuery.addHaving(Operator, Condition...)
This commit is contained in:
parent
498c2a4b11
commit
57fc2e252f
@ -52,6 +52,7 @@ proceduralStatement = [ label ]
|
||||
| declareStatement
|
||||
| assignmentStatement
|
||||
| ifStatement [ labelReference ]
|
||||
| caseStatement [ labelReference ]
|
||||
| loopStatement [ labelReference ]
|
||||
| forStatement [ labelReference ]
|
||||
| whileStatement [ labelReference ]
|
||||
@ -101,6 +102,16 @@ ifStatement =
|
||||
)
|
||||
;
|
||||
|
||||
caseStatement =
|
||||
'CASE'
|
||||
(
|
||||
field ( 'WHEN' field 'THEN' proceduralStatements )+
|
||||
| ( 'WHEN' condition 'THEN' proceduralStatements )+
|
||||
)
|
||||
[ 'ELSE' proceduralStatements ]
|
||||
'END CASE'
|
||||
;
|
||||
|
||||
loopStatement =
|
||||
'LOOP' proceduralStatements 'END LOOP'
|
||||
;
|
||||
@ -474,6 +485,7 @@ tableExpression =
|
||||
[ groupBy ]
|
||||
[ 'HAVING' condition ]
|
||||
[ 'WINDOW' windows ]
|
||||
[ 'QUALIFY' condition ]
|
||||
;
|
||||
|
||||
connectBy =
|
||||
|
||||
@ -41,7 +41,7 @@ package org.jooq;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A common interface for all objects holding conditions (e.g. queries)
|
||||
* A common interface for all objects holding conditions (e.g. queries).
|
||||
*
|
||||
* @author Lukas Eder
|
||||
* @deprecated - 2.6.0 [#1881] - This type will be removed from the public API,
|
||||
@ -53,7 +53,7 @@ public interface ConditionProvider {
|
||||
|
||||
/**
|
||||
* Adds a new condition to the query, connecting them to existing
|
||||
* conditions with {@link Operator#AND}
|
||||
* conditions with {@link Operator#AND}.
|
||||
*
|
||||
* @param condition The condition
|
||||
*/
|
||||
@ -62,7 +62,7 @@ public interface ConditionProvider {
|
||||
|
||||
/**
|
||||
* Adds new conditions to the query, connecting them to existing
|
||||
* conditions with {@link Operator#AND}
|
||||
* conditions with {@link Operator#AND}.
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@ -71,7 +71,7 @@ public interface ConditionProvider {
|
||||
|
||||
/**
|
||||
* Adds new conditions to the query, connecting them to existing
|
||||
* conditions with {@link Operator#AND}
|
||||
* conditions with {@link Operator#AND}.
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@ -80,7 +80,7 @@ public interface ConditionProvider {
|
||||
|
||||
/**
|
||||
* Adds a new condition to the query, connecting them to existing
|
||||
* conditions with the provided operator
|
||||
* conditions with the provided operator.
|
||||
*
|
||||
* @param condition The condition
|
||||
*/
|
||||
@ -89,7 +89,7 @@ public interface ConditionProvider {
|
||||
|
||||
/**
|
||||
* Adds new conditions to the query, connecting them to existing
|
||||
* conditions with the provided operator
|
||||
* conditions with the provided operator.
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@ -98,7 +98,7 @@ public interface ConditionProvider {
|
||||
|
||||
/**
|
||||
* Adds new conditions to the query, connecting them to existing
|
||||
* conditions with the provided operator
|
||||
* conditions with the provided operator.
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
|
||||
@ -347,7 +347,7 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
|
||||
/**
|
||||
* Adds a new condition to the having clause of query, connecting it with
|
||||
* each other with {@link Operator#AND}.
|
||||
* each other with <code>operator</code>.
|
||||
*
|
||||
* @param operator The operator to use to add the conditions to the existing
|
||||
* conditions
|
||||
@ -358,7 +358,7 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
|
||||
/**
|
||||
* Adds new conditions to the having clause of query, connecting them with
|
||||
* each other with {@link Operator#AND}.
|
||||
* each other with <code>operator</code>.
|
||||
*
|
||||
* @param operator The operator to use to add the conditions to the existing
|
||||
* conditions
|
||||
@ -369,7 +369,7 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
|
||||
/**
|
||||
* Adds new conditions to the having clause of query, connecting them with
|
||||
* each other with {@link Operator#AND}.
|
||||
* each other with <code>operator</code>.
|
||||
*
|
||||
* @param operator The operator to use to add the conditions to the existing
|
||||
* conditions
|
||||
@ -394,6 +394,66 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
@Support({ CUBRID, FIREBIRD_3_0, H2, MARIADB, MYSQL_8_0, POSTGRES, SQLITE })
|
||||
void addWindow(Collection<? extends WindowDefinition> definitions);
|
||||
|
||||
/**
|
||||
* Adds a new condition to the qualify clause of the query, connecting it
|
||||
* with each other with {@link Operator#AND}.
|
||||
*
|
||||
* @param condition The condition
|
||||
*/
|
||||
@Support({ H2 })
|
||||
void addQualify(Condition condition);
|
||||
|
||||
/**
|
||||
* Adds new conditions to the qualify clause of the query, connecting them
|
||||
* with each other with {@link Operator#AND}.
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ H2 })
|
||||
void addQualify(Condition... conditions);
|
||||
|
||||
/**
|
||||
* Adds new conditions to the qualify clause of the query, connecting them
|
||||
* with each other with {@link Operator#AND}.
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ H2 })
|
||||
void addQualify(Collection<? extends Condition> conditions);
|
||||
|
||||
/**
|
||||
* Adds a new condition to the qualify clause of query, connecting it with
|
||||
* each other with <code>operator</code>.
|
||||
*
|
||||
* @param operator The operator to use to add the conditions to the existing
|
||||
* conditions
|
||||
* @param condition The condition
|
||||
*/
|
||||
@Support({ H2 })
|
||||
void addQualify(Operator operator, Condition condition);
|
||||
|
||||
/**
|
||||
* Adds new conditions to the qualify clause of query, connecting them with
|
||||
* each other with <code>operator</code>.
|
||||
*
|
||||
* @param operator The operator to use to add the conditions to the existing
|
||||
* conditions
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ H2 })
|
||||
void addQualify(Operator operator, Condition... conditions);
|
||||
|
||||
/**
|
||||
* Adds new conditions to the qualify clause of query, connecting them with
|
||||
* each other with <code>operator</code>.
|
||||
*
|
||||
* @param operator The operator to use to add the conditions to the existing
|
||||
* conditions
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ H2 })
|
||||
void addQualify(Operator operator, Collection<? extends Condition> conditions);
|
||||
|
||||
/**
|
||||
* Add an Oracle-style hint to the select clause.
|
||||
* <p>
|
||||
|
||||
@ -117,7 +117,7 @@ import java.util.Collection;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface SelectWindowStep<R extends Record> extends SelectOrderByStep<R> {
|
||||
public interface SelectWindowStep<R extends Record> extends SelectQualifyStep<R> {
|
||||
|
||||
/**
|
||||
* Add a <code>WINDOW</code> clause to the statement.
|
||||
@ -142,7 +142,7 @@ public interface SelectWindowStep<R extends Record> extends SelectOrderByStep<R>
|
||||
* will inline window definitions where they are referenced.
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD_3_0, H2, MARIADB, MYSQL_8_0, POSTGRES, SQLITE })
|
||||
SelectOrderByStep<R> window(WindowDefinition... definitions);
|
||||
SelectQualifyStep<R> window(WindowDefinition... definitions);
|
||||
|
||||
/**
|
||||
* Add a <code>WINDOW</code> clause to the statement.
|
||||
@ -167,5 +167,5 @@ public interface SelectWindowStep<R extends Record> extends SelectOrderByStep<R>
|
||||
* will inline window definitions where they are referenced.
|
||||
*/
|
||||
@Support({ CUBRID, FIREBIRD_3_0, H2, MARIADB, MYSQL_8_0, POSTGRES, SQLITE })
|
||||
SelectOrderByStep<R> window(Collection<? extends WindowDefinition> definitions);
|
||||
SelectQualifyStep<R> window(Collection<? extends WindowDefinition> definitions);
|
||||
}
|
||||
|
||||
@ -232,6 +232,7 @@ final class Keywords {
|
||||
static final Keyword K_PRIMARY_KEY = keyword("primary key");
|
||||
static final Keyword K_PRIOR = keyword("prior");
|
||||
static final Keyword K_PUBLIC = keyword("public");
|
||||
static final Keyword K_QUALIFY = keyword("qualify");
|
||||
static final Keyword K_RAISE = keyword("raise");
|
||||
static final Keyword K_RAISERROR = keyword("raiserror");
|
||||
static final Keyword K_RECORD = keyword("record");
|
||||
|
||||
@ -1192,6 +1192,7 @@ final class ParserImpl implements Parser {
|
||||
List<GroupField> groupBy = null;
|
||||
Condition having = null;
|
||||
List<WindowDefinition> windows = null;
|
||||
Condition qualify = null;
|
||||
|
||||
if (parseKeywordIf(ctx, "INTO"))
|
||||
into = parseTableName(ctx);
|
||||
@ -1266,6 +1267,9 @@ final class ParserImpl implements Parser {
|
||||
if (parseKeywordIf(ctx, "WINDOW"))
|
||||
windows = parseWindowDefinitions(ctx);
|
||||
|
||||
if (parseKeywordIf(ctx, "QUALIFY"))
|
||||
qualify = parseCondition(ctx);
|
||||
|
||||
SelectQueryImpl<Record> result = new SelectQueryImpl<Record>(ctx.dsl.configuration(), with);
|
||||
if (hints != null)
|
||||
result.addHint(hints);
|
||||
@ -1306,6 +1310,9 @@ final class ParserImpl implements Parser {
|
||||
if (windows != null)
|
||||
result.addWindow(windows);
|
||||
|
||||
if (qualify != null)
|
||||
result.addQualify(qualify);
|
||||
|
||||
if (limit != null)
|
||||
if (offset != null)
|
||||
result.addLimit(inline((int) (long) offset), inline((int) (long) limit));
|
||||
@ -9730,6 +9737,7 @@ final class ParserImpl implements Parser {
|
||||
"OFFSET",
|
||||
"ORDER BY",
|
||||
"PARTITION BY",
|
||||
"QUALIFY",
|
||||
"RETURNING",
|
||||
"START WITH",
|
||||
"UNION",
|
||||
@ -9778,6 +9786,7 @@ final class ParserImpl implements Parser {
|
||||
"ORDER BY",
|
||||
"OUTER APPLY",
|
||||
"PARTITION BY",
|
||||
"QUALIFY",
|
||||
"RETURNING",
|
||||
"RIGHT ANTI JOIN",
|
||||
"RIGHT JOIN",
|
||||
|
||||
@ -99,6 +99,7 @@ import org.jooq.SelectLimitPercentStep;
|
||||
import org.jooq.SelectOnConditionStep;
|
||||
import org.jooq.SelectOnStep;
|
||||
import org.jooq.SelectOptionalOnStep;
|
||||
import org.jooq.SelectQualifyConditionStep;
|
||||
import org.jooq.SelectQuery;
|
||||
import org.jooq.SelectSeekLimitStep;
|
||||
import org.jooq.SelectSeekStep1;
|
||||
@ -147,6 +148,7 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
SelectConnectByAfterStartWithConditionStep<R>,
|
||||
SelectConnectByAfterStartWithStep<R>,
|
||||
SelectHavingConditionStep<R>,
|
||||
SelectQualifyConditionStep<R>,
|
||||
// [jooq-tools] START [implements-select-seek-step]
|
||||
SelectSeekStep1<R, T1>,
|
||||
SelectSeekStep2<R, T1, T2>,
|
||||
@ -422,6 +424,9 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
case ON:
|
||||
joinConditions.addConditions(condition);
|
||||
break;
|
||||
case QUALIFY:
|
||||
getQuery().addQualify(condition);
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
@ -498,6 +503,9 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
case ON:
|
||||
joinConditions.addConditions(Operator.OR, condition);
|
||||
break;
|
||||
case QUALIFY:
|
||||
getQuery().addQualify(Operator.OR, condition);
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
@ -1903,6 +1911,52 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(Condition conditions) {
|
||||
conditionStep = ConditionStep.QUALIFY;
|
||||
getQuery().addQualify(conditions);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(Condition... conditions) {
|
||||
conditionStep = ConditionStep.QUALIFY;
|
||||
getQuery().addQualify(conditions);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(Collection<? extends Condition> conditions) {
|
||||
conditionStep = ConditionStep.QUALIFY;
|
||||
getQuery().addQualify(conditions);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(Field<Boolean> condition) {
|
||||
return qualify(condition(condition));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(SQL sql) {
|
||||
return qualify(condition(sql));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(String sql) {
|
||||
return qualify(condition(sql));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(String sql, Object... bindings) {
|
||||
return qualify(condition(sql, bindings));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl qualify(String sql, QueryPart... parts) {
|
||||
return qualify(condition(sql, parts));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl on(Condition conditions) {
|
||||
conditionStep = ConditionStep.ON;
|
||||
@ -3878,6 +3932,12 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
* Additional conditions go to the <code>HAVING</code> clause that is
|
||||
* currently being added.
|
||||
*/
|
||||
HAVING
|
||||
HAVING,
|
||||
|
||||
/**
|
||||
* Additional conditions go to the <code>QUALIFY</code> clause that is
|
||||
* currently being added.
|
||||
*/
|
||||
QUALIFY
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,6 +115,7 @@ import static org.jooq.impl.Keywords.K_OF;
|
||||
import static org.jooq.impl.Keywords.K_ORDER;
|
||||
import static org.jooq.impl.Keywords.K_ORDER_BY;
|
||||
import static org.jooq.impl.Keywords.K_PERCENT;
|
||||
import static org.jooq.impl.Keywords.K_QUALIFY;
|
||||
import static org.jooq.impl.Keywords.K_SELECT;
|
||||
import static org.jooq.impl.Keywords.K_SIBLINGS;
|
||||
import static org.jooq.impl.Keywords.K_START_WITH;
|
||||
@ -255,6 +256,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
private QueryPartList<GroupField> groupBy;
|
||||
private final ConditionProviderImpl having;
|
||||
private WindowList window;
|
||||
private final ConditionProviderImpl qualify;
|
||||
private final SortFieldList orderBy;
|
||||
private boolean orderBySiblings;
|
||||
private final QueryPartList<Field<?>> seek;
|
||||
@ -291,6 +293,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
this.connectBy = new ConditionProviderImpl();
|
||||
this.connectByStartWith = new ConditionProviderImpl();
|
||||
this.having = new ConditionProviderImpl();
|
||||
this.qualify = new ConditionProviderImpl();
|
||||
this.orderBy = new SortFieldList();
|
||||
this.seek = new QueryPartList<Field<?>>();
|
||||
this.limit = new Limit();
|
||||
@ -1443,6 +1446,15 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
context.end(SELECT_HAVING);
|
||||
|
||||
// QUALIFY clause
|
||||
// -------------
|
||||
|
||||
if (getQualify().hasWhere())
|
||||
context.formatSeparator()
|
||||
.visit(K_QUALIFY)
|
||||
.sql(' ')
|
||||
.visit(getQualify());
|
||||
|
||||
// WINDOW clause
|
||||
// -------------
|
||||
context.start(SELECT_WINDOW);
|
||||
@ -2151,6 +2163,10 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
return having;
|
||||
}
|
||||
|
||||
final ConditionProviderImpl getQualify() {
|
||||
return qualify;
|
||||
}
|
||||
|
||||
final SortFieldList getOrderBy() {
|
||||
return (unionOp.size() == 0) ? orderBy : unionOrderBy;
|
||||
}
|
||||
@ -2397,6 +2413,36 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
window.addAll(definitions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addQualify(Condition conditions) {
|
||||
getQualify().addConditions(conditions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addQualify(Condition... conditions) {
|
||||
getQualify().addConditions(conditions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addQualify(Collection<? extends Condition> conditions) {
|
||||
getQualify().addConditions(conditions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addQualify(Operator operator, Condition conditions) {
|
||||
getQualify().addConditions(operator, conditions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addQualify(Operator operator, Condition... conditions) {
|
||||
getQualify().addConditions(operator, conditions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addQualify(Operator operator, Collection<? extends Condition> conditions) {
|
||||
getQualify().addConditions(operator, conditions);
|
||||
}
|
||||
|
||||
private final Select<R> combine(CombineOperator op, Select<? extends R> other) {
|
||||
int index = unionOp.size() - 1;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user