[#7659] Support any Number type for LIMIT .. OFFSET
This commit is contained in:
parent
3f76c48a0a
commit
af0d8e1750
@ -130,6 +130,16 @@ public interface SelectLimitAfterOffsetStep<R extends Record> extends SelectForU
|
||||
@Support
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(int numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, this may be emulated with a <code>ROW_NUMBER()</code> window
|
||||
* function and nested <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query using named parameters
|
||||
* <p>
|
||||
@ -143,6 +153,6 @@ public interface SelectLimitAfterOffsetStep<R extends Record> extends SelectForU
|
||||
* statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(Param<Integer> numberOfRows);
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(Param<? extends Number> numberOfRows);
|
||||
|
||||
}
|
||||
|
||||
@ -134,6 +134,19 @@ public interface SelectLimitStep<R extends Record> extends SelectForUpdateStep<R
|
||||
@Support
|
||||
SelectLimitPercentStep<R> limit(int numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, this may be emulated with a <code>ROW_NUMBER()</code> window
|
||||
* function and nested <code>SELECT</code> statements.
|
||||
* <p>
|
||||
* This is the same as calling {@link #limit(int, int)} with offset = 0, or
|
||||
* calling <code>.limit(numberOfRows).offset(0)</code>
|
||||
*/
|
||||
@Support
|
||||
SelectLimitPercentStep<R> limit(Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query using named parameters
|
||||
* <p>
|
||||
@ -150,7 +163,7 @@ public interface SelectLimitStep<R extends Record> extends SelectForUpdateStep<R
|
||||
* calling <code>.limit(numberOfRows).offset(0)</code>
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitPercentStep<R> limit(Param<Integer> numberOfRows);
|
||||
SelectLimitPercentStep<R> limit(Param<? extends Number> numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query
|
||||
@ -166,6 +179,20 @@ public interface SelectLimitStep<R extends Record> extends SelectForUpdateStep<R
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectWithTiesAfterOffsetStep<R> limit(int offset, int numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query
|
||||
* <p>
|
||||
* Note that some dialects do not support bind values at all in
|
||||
* <code>LIMIT</code> or <code>TOP</code> clauses!
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, or if your RDBMS does not natively support offsets, this is
|
||||
* emulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectWithTiesAfterOffsetStep<R> limit(Number offset, Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query using named parameters
|
||||
* <p>
|
||||
@ -181,6 +208,21 @@ public interface SelectLimitStep<R extends Record> extends SelectForUpdateStep<R
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(int offset, Param<Integer> numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query using named parameters
|
||||
* <p>
|
||||
* Note that some dialects do not support bind values at all in
|
||||
* <code>LIMIT</code> or <code>TOP</code> clauses!
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, or the <code>LIMIT</code> or <code>TOP</code> clause does not
|
||||
* support bind values, or if your RDBMS does not natively support offsets,
|
||||
* this may be emulated with a <code>ROW_NUMBER()</code> window function
|
||||
* and nested <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(Number offset, Param<? extends Number> numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query using named parameters
|
||||
* <p>
|
||||
@ -209,7 +251,22 @@ public interface SelectLimitStep<R extends Record> extends SelectForUpdateStep<R
|
||||
* and nested <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(Param<Integer> offset, Param<Integer> numberOfRows);
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(Param<? extends Number> offset, Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query using named parameters
|
||||
* <p>
|
||||
* Note that some dialects do not support bind values at all in
|
||||
* <code>LIMIT</code> or <code>TOP</code> clauses!
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, or the <code>LIMIT</code> or <code>TOP</code> clause does not
|
||||
* support bind values, or if your RDBMS does not natively support offsets,
|
||||
* this may be emulated with a <code>ROW_NUMBER()</code> window function
|
||||
* and nested <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitPercentAfterOffsetStep<R> limit(Param<? extends Number> offset, Param<? extends Number> numberOfRows);
|
||||
|
||||
/**
|
||||
* Add an <code>OFFSET</code> clause to the query
|
||||
@ -222,6 +279,17 @@ public interface SelectLimitStep<R extends Record> extends SelectForUpdateStep<R
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitAfterOffsetStep<R> offset(int offset);
|
||||
|
||||
/**
|
||||
* Add an <code>OFFSET</code> clause to the query
|
||||
* <p>
|
||||
* If there is no <code>LIMIT .. OFFSET</code> or <code>TOP</code> clause in
|
||||
* your RDBMS, or if your RDBMS does not natively support offsets, this is
|
||||
* emulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitAfterOffsetStep<R> offset(Number offset);
|
||||
|
||||
/**
|
||||
* Add an <code>OFFSET</code> clause to the query using a named parameter
|
||||
* <p>
|
||||
@ -231,5 +299,5 @@ public interface SelectLimitStep<R extends Record> extends SelectForUpdateStep<R
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectLimitAfterOffsetStep<R> offset(Param<Integer> offset);
|
||||
SelectLimitAfterOffsetStep<R> offset(Param<? extends Number> offset);
|
||||
}
|
||||
|
||||
@ -132,6 +132,17 @@ public interface SelectOffsetStep<R extends Record> extends SelectForUpdateStep<
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectForUpdateStep<R> offset(int offset);
|
||||
|
||||
/**
|
||||
* Add an <code>OFFSET</code> clause to the query.
|
||||
* <p>
|
||||
* If there is no <code>LIMIT .. OFFSET</code> or <code>TOP</code> clause in
|
||||
* your RDBMS, or if your RDBMS does not natively support offsets, this is
|
||||
* emulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectForUpdateStep<R> offset(Number offset);
|
||||
|
||||
/**
|
||||
* Add an <code>OFFSET</code> clause to the query using a named parameter.
|
||||
* <p>
|
||||
@ -141,5 +152,5 @@ public interface SelectOffsetStep<R extends Record> extends SelectForUpdateStep<
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectForUpdateStep<R> offset(Param<Integer> offset);
|
||||
SelectForUpdateStep<R> offset(Param<? extends Number> offset);
|
||||
}
|
||||
|
||||
@ -606,6 +606,17 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addOffset(int offset);
|
||||
|
||||
/**
|
||||
* Add an <code>OFFSET</code> clause to the query.
|
||||
* <p>
|
||||
* If there is no <code>LIMIT .. OFFSET</code> or <code>TOP</code> clause in
|
||||
* your RDBMS, or if your RDBMS does not natively support offsets, this is
|
||||
* emulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addOffset(Number offset);
|
||||
|
||||
/**
|
||||
* Add an <code>OFFSET</code> clause to the query using a named parameter.
|
||||
* <p>
|
||||
@ -615,7 +626,7 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addOffset(Param<Integer> offset);
|
||||
void addOffset(Param<? extends Number> offset);
|
||||
|
||||
/**
|
||||
* Limit the results of this select.
|
||||
@ -627,6 +638,16 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
@Support
|
||||
void addLimit(int numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select.
|
||||
* <p>
|
||||
* This is the same as calling {@link #addLimit(int, int)} with offset = 0
|
||||
*
|
||||
* @param numberOfRows The number of rows to return
|
||||
*/
|
||||
@Support
|
||||
void addLimit(Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select using named parameters.
|
||||
* <p>
|
||||
@ -644,7 +665,7 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
* @param numberOfRows The number of rows to return
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addLimit(Param<Integer> numberOfRows);
|
||||
void addLimit(Param<? extends Number> numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select.
|
||||
@ -663,6 +684,23 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addLimit(int offset, int numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select.
|
||||
* <p>
|
||||
* Note that some dialects do not support bind values at all in
|
||||
* <code>LIMIT</code> or <code>TOP</code> clauses!
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, or if your RDBMS does not natively support offsets, this is
|
||||
* emulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*
|
||||
* @param offset The lowest offset starting at 0
|
||||
* @param numberOfRows The number of rows to return
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addLimit(Number offset, Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select.
|
||||
* <p>
|
||||
@ -681,6 +719,24 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addLimit(Param<Integer> offset, int numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select.
|
||||
* <p>
|
||||
* Note that some dialects do not support bind values at all in
|
||||
* <code>LIMIT</code> or <code>TOP</code> clauses!
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, or the <code>LIMIT</code> or <code>TOP</code> clause does not
|
||||
* support bind values, or if your RDBMS does not natively support offsets,
|
||||
* this may be emulated with a <code>ROW_NUMBER()</code> window function
|
||||
* and nested <code>SELECT</code> statements.
|
||||
*
|
||||
* @param offset The lowest offset starting at 0
|
||||
* @param numberOfRows The number of rows to return
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addLimit(Param<? extends Number> offset, Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select using named parameters.
|
||||
* <p>
|
||||
@ -715,7 +771,25 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
|
||||
* @param numberOfRows The number of rows to return
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addLimit(Param<Integer> offset, Param<Integer> numberOfRows);
|
||||
void addLimit(Number offset, Param<? extends Number> numberOfRows);
|
||||
|
||||
/**
|
||||
* Limit the results of this select using named parameters.
|
||||
* <p>
|
||||
* Note that some dialects do not support bind values at all in
|
||||
* <code>LIMIT</code> or <code>TOP</code> clauses!
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, or the <code>LIMIT</code> or <code>TOP</code> clause does not
|
||||
* support bind values, or if your RDBMS does not natively support offsets,
|
||||
* this may be emulated with a <code>ROW_NUMBER()</code> window function
|
||||
* and nested <code>SELECT</code> statements.
|
||||
*
|
||||
* @param offset The lowest offset starting at 0
|
||||
* @param numberOfRows The number of rows to return
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
void addLimit(Param<? extends Number> offset, Param<? extends Number> numberOfRows);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -127,6 +127,16 @@ public interface SelectSeekLimitStep<R extends Record> extends SelectForUpdateSt
|
||||
@Support
|
||||
SelectForUpdateStep<R> limit(int numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query.
|
||||
* <p>
|
||||
* If there is no <code>LIMIT</code> or <code>TOP</code> clause in your
|
||||
* RDBMS, this may be emulated with a <code>ROW_NUMBER()</code> window
|
||||
* function and nested <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support
|
||||
SelectForUpdateStep<R> limit(Number numberOfRows);
|
||||
|
||||
/**
|
||||
* Add a <code>LIMIT</code> clause to the query using named parameters.
|
||||
* <p>
|
||||
@ -140,6 +150,6 @@ public interface SelectSeekLimitStep<R extends Record> extends SelectForUpdateSt
|
||||
* statements.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
SelectForUpdateStep<R> limit(Param<Integer> numberOfRows);
|
||||
SelectForUpdateStep<R> limit(Param<? extends Number> numberOfRows);
|
||||
|
||||
}
|
||||
|
||||
@ -40,7 +40,6 @@ package org.jooq.impl;
|
||||
import static org.jooq.RenderContext.CastMode.NEVER;
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.one;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.DSL.zero;
|
||||
@ -58,6 +57,7 @@ import static org.jooq.impl.Keywords.K_START_AT;
|
||||
import static org.jooq.impl.Keywords.K_TO;
|
||||
import static org.jooq.impl.Keywords.K_TOP;
|
||||
import static org.jooq.impl.Keywords.K_WITH_TIES;
|
||||
import static org.jooq.impl.SQLDataType.BIGINT;
|
||||
import static org.jooq.impl.Tools.DataKey.DATA_PREFER_TOP_OVER_FETCH;
|
||||
|
||||
import org.jooq.Clause;
|
||||
@ -81,11 +81,11 @@ final class Limit extends AbstractQueryPart {
|
||||
private static final Field<Integer> ONE = one();
|
||||
private static final Param<Integer> MAX = DSL.inline(Integer.MAX_VALUE);
|
||||
|
||||
private Field<Integer> numberOfRows;
|
||||
private Field<Integer> numberOfRowsOrMax = MAX;
|
||||
private Field<Integer> offset;
|
||||
private Field<Integer> offsetOrZero = ZERO;
|
||||
private Field<Integer> offsetPlusOne = ONE;
|
||||
private Field<?> numberOfRows;
|
||||
private Field<?> numberOfRowsOrMax = MAX;
|
||||
private Field<?> offset;
|
||||
private Field<?> offsetOrZero = ZERO;
|
||||
private Field<?> offsetPlusOne = ONE;
|
||||
private boolean rendersParams;
|
||||
private boolean withTies;
|
||||
|
||||
@ -149,7 +149,7 @@ final class Limit extends AbstractQueryPart {
|
||||
ctx.castMode(NEVER)
|
||||
.formatSeparator()
|
||||
.visit(K_ROWS)
|
||||
.sql(' ').visit(getLowerRownum().add(inline(1, SQLDataType.INTEGER)))
|
||||
.sql(' ').visit(getLowerRownum().add(ONE))
|
||||
.sql(' ').visit(K_TO)
|
||||
.sql(' ').visit(getUpperRownum())
|
||||
.castMode(castMode);
|
||||
@ -385,7 +385,7 @@ final class Limit extends AbstractQueryPart {
|
||||
&& !withTies()
|
||||
|
||||
&& numberOfRows instanceof Param
|
||||
&& Integer.valueOf(1).equals(((Param<?>) numberOfRows).getValue());
|
||||
&& Long.valueOf(1L).equals(((Param<?>) numberOfRows).getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,14 +398,14 @@ final class Limit extends AbstractQueryPart {
|
||||
/**
|
||||
* The lower bound, such that ROW_NUMBER() > getLowerRownum()
|
||||
*/
|
||||
final Field<Integer> getLowerRownum() {
|
||||
final Field<?> getLowerRownum() {
|
||||
return offsetOrZero;
|
||||
}
|
||||
|
||||
/**
|
||||
* The upper bound, such that ROW_NUMBER() <= getUpperRownum()
|
||||
*/
|
||||
final Field<Integer> getUpperRownum() {
|
||||
final Field<?> getUpperRownum() {
|
||||
return offsetOrZero.add(numberOfRowsOrMax);
|
||||
}
|
||||
|
||||
@ -428,26 +428,26 @@ final class Limit extends AbstractQueryPart {
|
||||
return rendersParams;
|
||||
}
|
||||
|
||||
final void setOffset(int offset) {
|
||||
if (offset != 0) {
|
||||
this.offset = val(offset, SQLDataType.INTEGER);
|
||||
final void setOffset(Number offset) {
|
||||
if (offset.longValue() != 0L) {
|
||||
this.offset = val(offset.longValue(), BIGINT);
|
||||
this.offsetOrZero = this.offset;
|
||||
this.offsetPlusOne = val(offset + 1, SQLDataType.INTEGER);
|
||||
this.offsetPlusOne = val(offset.longValue() + 1L, BIGINT);
|
||||
}
|
||||
}
|
||||
|
||||
final void setOffset(Param<Integer> offset) {
|
||||
final void setOffset(Param<? extends Number> offset) {
|
||||
this.offset = offset;
|
||||
this.offsetOrZero = offset;
|
||||
this.rendersParams = rendersParams |= offset.isInline();
|
||||
}
|
||||
|
||||
final void setNumberOfRows(int numberOfRows) {
|
||||
this.numberOfRows = val(numberOfRows, SQLDataType.INTEGER);
|
||||
final void setNumberOfRows(Number numberOfRows) {
|
||||
this.numberOfRows = val(numberOfRows.longValue(), SQLDataType.BIGINT);
|
||||
this.numberOfRowsOrMax = this.numberOfRows;
|
||||
}
|
||||
|
||||
final void setNumberOfRows(Param<Integer> numberOfRows) {
|
||||
final void setNumberOfRows(Param<? extends Number> numberOfRows) {
|
||||
this.numberOfRows = numberOfRows;
|
||||
this.numberOfRowsOrMax = numberOfRows;
|
||||
this.rendersParams |= numberOfRows.isInline();
|
||||
|
||||
@ -181,40 +181,40 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -5425308887382166448L;
|
||||
private static final long serialVersionUID = -5425308887382166448L;
|
||||
|
||||
/**
|
||||
* A temporary member holding a join table
|
||||
*/
|
||||
private transient TableLike<?> joinTable;
|
||||
private transient TableLike<?> joinTable;
|
||||
|
||||
/**
|
||||
* A temporary member holding a join partition by expression
|
||||
*/
|
||||
private transient Field<?>[] joinPartitionBy;
|
||||
private transient Field<?>[] joinPartitionBy;
|
||||
|
||||
/**
|
||||
* A temporary member holding a join type
|
||||
*/
|
||||
private transient JoinType joinType;
|
||||
private transient JoinType joinType;
|
||||
|
||||
/**
|
||||
* A temporary member holding a join condition
|
||||
*/
|
||||
private transient ConditionProviderImpl joinConditions;
|
||||
private transient ConditionProviderImpl joinConditions;
|
||||
|
||||
/**
|
||||
* The step that is currently receiving new conditions
|
||||
*/
|
||||
private transient ConditionStep conditionStep;
|
||||
private transient ConditionStep conditionStep;
|
||||
|
||||
/**
|
||||
* The limit that has been added in a limit(int).offset(int) construct
|
||||
* The limit that has been added in a limit(Number).offset(Number) construct
|
||||
*/
|
||||
private transient Integer limit;
|
||||
private transient Param<Integer> limitParam;
|
||||
private transient Integer offset;
|
||||
private transient Param<Integer> offsetParam;
|
||||
private transient Number limit;
|
||||
private transient Param<? extends Number> limitParam;
|
||||
private transient Number offset;
|
||||
private transient Param<? extends Number> offsetParam;
|
||||
|
||||
SelectImpl(Configuration configuration, WithImpl with) {
|
||||
this(configuration, with, false);
|
||||
@ -1598,13 +1598,18 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(int l) {
|
||||
return limit((Number) l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(Number l) {
|
||||
limit = l;
|
||||
limitParam = null;
|
||||
return limitOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(Param<Integer> l) {
|
||||
public final SelectImpl limit(Param<? extends Number> l) {
|
||||
limit = null;
|
||||
limitParam = l;
|
||||
return limitOffset();
|
||||
@ -1612,6 +1617,11 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(int o, int l) {
|
||||
return limit((Number) o, (Number) l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(Number o, Number l) {
|
||||
offset = o;
|
||||
offsetParam = null;
|
||||
limit = l;
|
||||
@ -1621,6 +1631,11 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(int o, Param<Integer> l) {
|
||||
return limit((Number) o, l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(Number o, Param<? extends Number> l) {
|
||||
offset = o;
|
||||
offsetParam = null;
|
||||
limit = null;
|
||||
@ -1630,6 +1645,11 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(Param<Integer> o, int l) {
|
||||
return limit(o, (Number) l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(Param<? extends Number> o, Number l) {
|
||||
offset = null;
|
||||
offsetParam = o;
|
||||
limit = l;
|
||||
@ -1638,7 +1658,7 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl limit(Param<Integer> o, Param<Integer> l) {
|
||||
public final SelectImpl limit(Param<? extends Number> o, Param<? extends Number> l) {
|
||||
offset = null;
|
||||
offsetParam = o;
|
||||
limit = null;
|
||||
@ -1648,13 +1668,18 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
|
||||
@Override
|
||||
public final SelectImpl offset(int o) {
|
||||
return offset((Number) o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl offset(Number o) {
|
||||
offset = o;
|
||||
offsetParam = null;
|
||||
return limitOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SelectImpl offset(Param<Integer> o) {
|
||||
public final SelectImpl offset(Param<? extends Number> o) {
|
||||
offset = null;
|
||||
offsetParam = o;
|
||||
return limitOffset();
|
||||
|
||||
@ -1774,44 +1774,69 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
@Override
|
||||
public final void addOffset(int offset) {
|
||||
addOffset((Number) offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addOffset(Number offset) {
|
||||
getLimit().setOffset(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addOffset(Param<Integer> offset) {
|
||||
public final void addOffset(Param<? extends Number> offset) {
|
||||
getLimit().setOffset(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(int numberOfRows) {
|
||||
addLimit((Number) numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(Number numberOfRows) {
|
||||
getLimit().setNumberOfRows(numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(Param<Integer> numberOfRows) {
|
||||
public final void addLimit(Param<? extends Number> numberOfRows) {
|
||||
getLimit().setNumberOfRows(numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(int offset, int numberOfRows) {
|
||||
addLimit((Number) offset, (Number) numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(Number offset, Number numberOfRows) {
|
||||
getLimit().setOffset(offset);
|
||||
getLimit().setNumberOfRows(numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(int offset, Param<Integer> numberOfRows) {
|
||||
addLimit((Number) offset, numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(Number offset, Param<? extends Number> numberOfRows) {
|
||||
getLimit().setOffset(offset);
|
||||
getLimit().setNumberOfRows(numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(Param<Integer> offset, int numberOfRows) {
|
||||
addLimit(offset, (Number) numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(Param<? extends Number> offset, Number numberOfRows) {
|
||||
getLimit().setOffset(offset);
|
||||
getLimit().setNumberOfRows(numberOfRows);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addLimit(Param<Integer> offset, Param<Integer> numberOfRows) {
|
||||
public final void addLimit(Param<? extends Number> offset, Param<? extends Number> numberOfRows) {
|
||||
getLimit().setOffset(offset);
|
||||
getLimit().setNumberOfRows(numberOfRows);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user