[#714] Add support for non-standard ORDER BY .. LIMIT clauses in UPDATE, DELETE statements

This commit is contained in:
Lukas Eder 2018-08-29 14:16:13 +02:00
parent d981c45f21
commit 6d54d3246f
16 changed files with 617 additions and 18 deletions

View File

@ -71,7 +71,7 @@ import org.jooq.impl.DSL;
*
* @author Lukas Eder
*/
public interface DeleteConditionStep<R extends Record> extends DeleteReturningStep<R> {
public interface DeleteConditionStep<R extends Record> extends DeleteOrderByStep<R> {
/**
* Combine the currently assembled conditions with another one using the

View File

@ -0,0 +1,88 @@
/*
* 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.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
/**
* This type is used for the {@link Delete}'s DSL API.
* <p>
* Example: <code><pre>
* DSLContext create = DSL.using(configuration);
*
* create.delete(table)
* .where(field1.greaterThan(100))
* .execute();
* </pre></code>
* <p>
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
* <p>
* It is usually not recommended to reference any <code>XYZ*Step</code> types
* directly from client code, or assign them to local variables. When writing
* dynamic SQL, creating a statement's components dynamically, and passing them
* to the DSL API statically is usually a better choice. See the manual's
* section about dynamic SQL for details: <a href=
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
* <p>
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
* <ul>
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
* <li>They're less composable and not easy to get right when dynamic SQL gets
* complex</li>
* <li>They're less readable</li>
* <li>They might have binary incompatible changes between minor releases</li>
* </ul>
*
* @author Lukas Eder
*/
public interface DeleteLimitStep<R extends Record> extends DeleteReturningStep<R> {
/**
* Add a <code>LIMIT</code> clause to the query
*/
@Support({ MARIADB, MYSQL })
DeleteReturningStep<R> limit(Number numberOfRows);
/**
* Add a <code>LIMIT</code> clause to the query using named parameters
*/
@Support({ MARIADB, MYSQL })
DeleteReturningStep<R> limit(Param<? extends Number> numberOfRows);
}

View File

@ -0,0 +1,102 @@
/*
* 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.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
import java.util.Collection;
/**
* This type is used for the {@link Delete}'s DSL API.
* <p>
* Example: <code><pre>
* DSLContext create = DSL.using(configuration);
*
* create.delete(table)
* .where(field1.greaterThan(100))
* .execute();
* </pre></code>
* <p>
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
* <p>
* It is usually not recommended to reference any <code>XYZ*Step</code> types
* directly from client code, or assign them to local variables. When writing
* dynamic SQL, creating a statement's components dynamically, and passing them
* to the DSL API statically is usually a better choice. See the manual's
* section about dynamic SQL for details: <a href=
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
* <p>
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
* <ul>
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
* <li>They're less composable and not easy to get right when dynamic SQL gets
* complex</li>
* <li>They're less readable</li>
* <li>They might have binary incompatible changes between minor releases</li>
* </ul>
*
* @author Lukas Eder
*/
public interface DeleteOrderByStep<R extends Record> extends DeleteLimitStep<R> {
/**
* Add an <code>ORDER BY</code> clause to the query
*/
@Support({ MARIADB, MYSQL })
DeleteLimitStep<R> orderBy(OrderField<?>... fields);
/**
* Add an <code>ORDER BY</code> clause to the query
*/
@Support({ MARIADB, MYSQL })
DeleteLimitStep<R> orderBy(Collection<? extends OrderField<?>> fields);
/**
* Add an <code>ORDER BY</code> clause to the query
* <p>
* Indexes start at <code>1</code> in SQL!
* <p>
* Note, you can use <code>orderBy(DSL.val(1).desc())</code> or
* <code>orderBy(DSL.literal(1).desc())</code> to apply descending
* ordering
*/
@Support({ MARIADB, MYSQL })
DeleteLimitStep<R> orderBy(int... fieldIndexes);
}

View File

@ -38,9 +38,12 @@
package org.jooq;
// ...
// ...
// ...
import static org.jooq.SQLDialect.FIREBIRD;
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
@ -101,6 +104,38 @@ public interface DeleteQuery<R extends Record> extends ConditionProvider, Delete
@Support
void addConditions(Operator operator, Collection<? extends Condition> conditions);
/**
* Adds ordering fields.
*
* @param fields The ordering fields
*/
@Support({ MARIADB, MYSQL })
void addOrderBy(OrderField<?>... fields);
/**
* Adds ordering fields.
*
* @param fields The ordering fields
*/
@Support({ MARIADB, MYSQL })
void addOrderBy(Collection<? extends OrderField<?>> fields);
/**
* Limit the results of this select.
*
* @param numberOfRows The number of rows to return
*/
@Support({ MARIADB, MYSQL })
void addLimit(Number numberOfRows);
/**
* Limit the results of this select using named parameters.
*
* @param numberOfRows The number of rows to return
*/
@Support({ MARIADB, MYSQL })
void addLimit(Param<? extends Number> numberOfRows);
// ------------------------------------------------------------------------
// XXX: Methods for the DELETE .. RETURNING syntax
// ------------------------------------------------------------------------

View File

@ -72,7 +72,7 @@ import org.jooq.impl.DSL;
*
* @author Lukas Eder
*/
public interface DeleteWhereStep<R extends Record> extends DeleteReturningStep<R> {
public interface DeleteWhereStep<R extends Record> extends DeleteOrderByStep<R> {
/**
* Add conditions to the query, connecting them with each other with

View File

@ -73,7 +73,7 @@ import org.jooq.impl.DSL;
*
* @author Lukas Eder
*/
public interface UpdateConditionStep<R extends Record> extends UpdateReturningStep<R> {
public interface UpdateConditionStep<R extends Record> extends UpdateOrderByStep<R> {
/**
* Combine the currently assembled conditions with another one using the

View File

@ -0,0 +1,92 @@
/*
* 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.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
/**
* This type is used for the {@link Update}'s DSL API.
* <p>
* Example: <code><pre>
* DSLContext create = DSL.using(configuration);
*
* create.update(table)
* .set(field1, value1)
* .set(field2, value2)
* .where(field1.greaterThan(100))
* .execute();
* </pre></code>
* <p>
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
* <p>
* It is usually not recommended to reference any <code>XYZ*Step</code> types
* directly from client code, or assign them to local variables. When writing
* dynamic SQL, creating a statement's components dynamically, and passing them
* to the DSL API statically is usually a better choice. See the manual's
* section about dynamic SQL for details: <a href=
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
* <p>
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
* <ul>
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
* <li>They're less composable and not easy to get right when dynamic SQL gets
* complex</li>
* <li>They're less readable</li>
* <li>They might have binary incompatible changes between minor releases</li>
* </ul>
*
* @author Lukas Eder
*/
public interface UpdateLimitStep<R extends Record> extends UpdateReturningStep<R> {
/**
* Add a <code>LIMIT</code> clause to the query
*/
@Support({ MARIADB, MYSQL })
UpdateReturningStep<R> limit(Number numberOfRows);
/**
* Add a <code>LIMIT</code> clause to the query using named parameters
*/
@Support({ MARIADB, MYSQL })
UpdateReturningStep<R> limit(Param<? extends Number> numberOfRows);
}

View File

@ -0,0 +1,105 @@
/*
* 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.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
import java.util.Collection;
/**
* This type is used for the {@link Update}'s DSL API.
* <p>
* Example: <code><pre>
* DSLContext create = DSL.using(configuration);
*
* create.update(table)
* .set(field1, value1)
* .set(field2, value2)
* .where(field1.greaterThan(100))
* .execute();
* </pre></code>
* <p>
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
* <p>
* It is usually not recommended to reference any <code>XYZ*Step</code> types
* directly from client code, or assign them to local variables. When writing
* dynamic SQL, creating a statement's components dynamically, and passing them
* to the DSL API statically is usually a better choice. See the manual's
* section about dynamic SQL for details: <a href=
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
* <p>
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
* <ul>
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
* <li>They're less composable and not easy to get right when dynamic SQL gets
* complex</li>
* <li>They're less readable</li>
* <li>They might have binary incompatible changes between minor releases</li>
* </ul>
*
* @author Lukas Eder
*/
public interface UpdateOrderByStep<R extends Record> extends UpdateLimitStep<R> {
/**
* Add an <code>ORDER BY</code> clause to the query
*/
@Support({ MARIADB, MYSQL })
UpdateLimitStep<R> orderBy(OrderField<?>... fields);
/**
* Add an <code>ORDER BY</code> clause to the query
*/
@Support({ MARIADB, MYSQL })
UpdateLimitStep<R> orderBy(Collection<? extends OrderField<?>> fields);
/**
* Add an <code>ORDER BY</code> clause to the query
* <p>
* Indexes start at <code>1</code> in SQL!
* <p>
* Note, you can use <code>orderBy(DSL.val(1).desc())</code> or
* <code>orderBy(DSL.literal(1).desc())</code> to apply descending
* ordering
*/
@Support({ MARIADB, MYSQL })
UpdateLimitStep<R> orderBy(int... fieldIndexes);
}

View File

@ -38,6 +38,7 @@
package org.jooq;
// ...
// ...
// ...
import static org.jooq.SQLDialect.FIREBIRD;
@ -45,6 +46,8 @@ 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;
// ...
@ -411,6 +414,38 @@ public interface UpdateQuery<R extends Record> extends StoreQuery<R>, ConditionP
@Support
void addConditions(Operator operator, Collection<? extends Condition> conditions);
/**
* Adds ordering fields.
*
* @param fields The ordering fields
*/
@Support({ MARIADB, MYSQL })
void addOrderBy(OrderField<?>... fields);
/**
* Adds ordering fields.
*
* @param fields The ordering fields
*/
@Support({ MARIADB, MYSQL })
void addOrderBy(Collection<? extends OrderField<?>> fields);
/**
* Limit the results of this select.
*
* @param numberOfRows The number of rows to return
*/
@Support({ MARIADB, MYSQL })
void addLimit(Number numberOfRows);
/**
* Limit the results of this select using named parameters.
*
* @param numberOfRows The number of rows to return
*/
@Support({ MARIADB, MYSQL })
void addLimit(Param<? extends Number> numberOfRows);
// ------------------------------------------------------------------------
// XXX: Methods for the UPDATE .. RETURNING syntax
// ------------------------------------------------------------------------

View File

@ -74,7 +74,7 @@ import org.jooq.impl.DSL;
*
* @author Lukas Eder
*/
public interface UpdateWhereStep<R extends Record> extends UpdateReturningStep<R> {
public interface UpdateWhereStep<R extends Record> extends UpdateOrderByStep<R> {
/**
* Add conditions to the query, connecting them with each other with

View File

@ -52,6 +52,8 @@ import org.jooq.DeleteResultStep;
import org.jooq.DeleteWhereStep;
import org.jooq.Field;
import org.jooq.Operator;
import org.jooq.OrderField;
import org.jooq.Param;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.Record1;
@ -291,6 +293,35 @@ final class DeleteImpl<R extends Record>
return or(notExists(select));
}
@Override
public final DeleteImpl<R> orderBy(OrderField<?>... fields) {
getDelegate().addOrderBy(fields);
return this;
}
@Override
public final DeleteImpl<R> orderBy(Collection<? extends OrderField<?>> fields) {
getDelegate().addOrderBy(fields);
return this;
}
@Override
public final DeleteImpl<R> orderBy(int... fieldIndexes) {
return orderBy(Tools.inline(fieldIndexes));
}
@Override
public final DeleteImpl<R> limit(Number numberOfRows) {
getDelegate().addLimit(numberOfRows);
return this;
}
@Override
public final DeleteImpl<R> limit(Param<? extends Number> numberOfRows) {
getDelegate().addLimit(numberOfRows);
return this;
}
@Override
public final DeleteImpl<R> returning() {
getDelegate().setReturning();

View File

@ -48,8 +48,11 @@ import static org.jooq.SQLDialect.MYSQL;
import static org.jooq.conf.SettingsTools.getExecuteDeleteWithoutWhere;
import static org.jooq.impl.Keywords.K_DELETE;
import static org.jooq.impl.Keywords.K_FROM;
import static org.jooq.impl.Keywords.K_LIMIT;
import static org.jooq.impl.Keywords.K_ORDER_BY;
import static org.jooq.impl.Keywords.K_WHERE;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
@ -59,6 +62,8 @@ import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.DeleteQuery;
import org.jooq.Operator;
import org.jooq.OrderField;
import org.jooq.Param;
import org.jooq.Record;
import org.jooq.SQLDialect;
import org.jooq.Table;
@ -72,12 +77,15 @@ final class DeleteQueryImpl<R extends Record> extends AbstractDMLQuery<R> implem
private static final Clause[] CLAUSES = { DELETE };
private static final EnumSet<SQLDialect> SPECIAL_DELETE_AS_SYNTAX = EnumSet.of(MARIADB, MYSQL);
private final ConditionProviderImpl condition;
private final ConditionProviderImpl condition;
private final SortFieldList orderBy;
private Param<?> limit;
DeleteQueryImpl(Configuration configuration, WithImpl with, Table<R> table) {
super(configuration, with, table);
this.condition = new ConditionProviderImpl();
this.orderBy = new SortFieldList();
}
final Condition getWhere() {
@ -118,6 +126,26 @@ final class DeleteQueryImpl<R extends Record> extends AbstractDMLQuery<R> implem
condition.addConditions(operator, conditions);
}
@Override
public final void addOrderBy(OrderField<?>... fields) {
addOrderBy(Arrays.asList(fields));
}
@Override
public final void addOrderBy(Collection<? extends OrderField<?>> fields) {
orderBy.addAll(Tools.sortFields(fields));
}
@Override
public final void addLimit(Number numberOfRows) {
addLimit(DSL.val(numberOfRows));
}
@Override
public final void addLimit(Param<? extends Number> numberOfRows) {
limit = numberOfRows;
}
@Override
final void accept0(Context<?> ctx) {
boolean declare = ctx.declareTables();
@ -147,11 +175,20 @@ final class DeleteQueryImpl<R extends Record> extends AbstractDMLQuery<R> implem
.visit(K_WHERE).sql(' ')
.visit(getWhere());
ctx.end(DELETE_WHERE)
.start(DELETE_RETURNING);
ctx.end(DELETE_WHERE);
if (!orderBy.isEmpty())
ctx.formatSeparator()
.visit(K_ORDER_BY).sql(' ')
.visit(orderBy);
if (limit != null)
ctx.formatSeparator()
.visit(K_LIMIT).sql(' ')
.visit(limit);
ctx.start(DELETE_RETURNING);
toSQLReturning(ctx);
ctx.end(DELETE_RETURNING);
}

View File

@ -2174,13 +2174,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
@Override
public final void addOrderBy(int... fieldIndexes) {
Field<?>[] fields = new Field[fieldIndexes.length];
for (int i = 0; i < fieldIndexes.length; i++) {
fields[i] = inline(fieldIndexes[i]);
}
addOrderBy(fields);
addOrderBy(Tools.inline(fieldIndexes));
}
@Override

View File

@ -1601,6 +1601,19 @@ final class Tools {
return result;
}
@SuppressWarnings("unchecked")
static final Field<Integer>[] inline(int[] fieldIndexes) {
if (fieldIndexes == null)
return (Field<Integer>[]) EMPTY_FIELD;
Field<Integer>[] result = new Field[fieldIndexes.length];
for (int i = 0; i < fieldIndexes.length; i++)
result[i] = DSL.inline(fieldIndexes[i]);
return result;
}
/**
* A utility method that fails with an exception if
* {@link Row#indexOf(Field)} doesn't return any index.

View File

@ -52,6 +52,8 @@ import org.jooq.Configuration;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.Operator;
import org.jooq.OrderField;
import org.jooq.Param;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.Record1;
@ -679,6 +681,35 @@ final class UpdateImpl<R extends Record>
return or(notExists(select));
}
@Override
public final UpdateImpl<R> orderBy(OrderField<?>... fields) {
getDelegate().addOrderBy(fields);
return this;
}
@Override
public final UpdateImpl<R> orderBy(Collection<? extends OrderField<?>> fields) {
getDelegate().addOrderBy(fields);
return this;
}
@Override
public final UpdateImpl<R> orderBy(int... fieldIndexes) {
return orderBy(Tools.inline(fieldIndexes));
}
@Override
public final UpdateImpl<R> limit(Number numberOfRows) {
getDelegate().addLimit(numberOfRows);
return this;
}
@Override
public final UpdateImpl<R> limit(Param<? extends Number> numberOfRows) {
getDelegate().addLimit(numberOfRows);
return this;
}
@Override
public final UpdateImpl<R> returning() {
getDelegate().setReturning();

View File

@ -60,6 +60,8 @@ import static org.jooq.SQLDialect.POSTGRES_10;
import static org.jooq.conf.SettingsTools.getExecuteUpdateWithoutWhere;
import static org.jooq.impl.DSL.select;
import static org.jooq.impl.Keywords.K_FROM;
import static org.jooq.impl.Keywords.K_LIMIT;
import static org.jooq.impl.Keywords.K_ORDER_BY;
import static org.jooq.impl.Keywords.K_ROW;
import static org.jooq.impl.Keywords.K_SET;
import static org.jooq.impl.Keywords.K_UPDATE;
@ -76,6 +78,8 @@ import org.jooq.Configuration;
import org.jooq.Context;
import org.jooq.Field;
import org.jooq.Operator;
import org.jooq.OrderField;
import org.jooq.Param;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record10;
@ -147,6 +151,8 @@ final class UpdateQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
private Row multiRow;
private Row multiValue;
private Select<?> multiSelect;
private final SortFieldList orderBy;
private Param<?> limit;
UpdateQueryImpl(Configuration configuration, WithImpl with, Table<R> table) {
super(configuration, with, table);
@ -154,6 +160,7 @@ final class UpdateQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
this.updateMap = new FieldMapForUpdate(table, UPDATE_SET_ASSIGNMENT);
this.from = new TableList();
this.condition = new ConditionProviderImpl();
this.orderBy = new SortFieldList();
}
@Override
@ -456,6 +463,26 @@ final class UpdateQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
condition.addConditions(operator, conditions);
}
@Override
public final void addOrderBy(OrderField<?>... fields) {
addOrderBy(Arrays.asList(fields));
}
@Override
public final void addOrderBy(Collection<? extends OrderField<?>> fields) {
orderBy.addAll(Tools.sortFields(fields));
}
@Override
public final void addLimit(Number numberOfRows) {
addLimit(DSL.val(numberOfRows));
}
@Override
public final void addLimit(Param<? extends Number> numberOfRows) {
limit = numberOfRows;
}
final Condition getWhere() {
return condition.getWhere();
}
@ -609,11 +636,20 @@ final class UpdateQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
.visit(K_WHERE).sql(' ')
.visit(getWhere());
ctx.end(UPDATE_WHERE)
.start(UPDATE_RETURNING);
ctx.end(UPDATE_WHERE);
if (!orderBy.isEmpty())
ctx.formatSeparator()
.visit(K_ORDER_BY).sql(' ')
.visit(orderBy);
if (limit != null)
ctx.formatSeparator()
.visit(K_LIMIT).sql(' ')
.visit(limit);
ctx.start(UPDATE_RETURNING);
toSQLReturning(ctx);
ctx.end(UPDATE_RETURNING);
}