Skip to content

Commit

Permalink
feat!: EXPOSED-497 Allow OFFSET without LIMIT in query
Browse files Browse the repository at this point in the history
- Add default values to new interface members so implementations don't break
- Remove default argument from old limit() to not conflict with new limit()
- Update breaking changes document
  • Loading branch information
bog-walk committed Sep 5, 2024
1 parent 2dfc750 commit 0d67e47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions documentation-website/Writerside/topics/Breaking-Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
This enables the use of the new `Join.delete()` function, which performs a delete operation on a specific table from the join relation.
The original statement class constructor has also been deprecated in favor of the constructor that accepts `targetsSet`, as well as another
additional parameter `targetTables` (for specifying which table from the join relation, if applicable, to delete from).
* The `SizedIterable.limit(n, offset)` is now deprecated in favor of 2 independent methods, `limit()` and `offset()`.
* `SizedIterable.limit(n, offset)` is now deprecated in favor of 2 independent methods, `limit()` and `offset()`.
In supporting databases, this allows the generation of an OFFSET clause in the SELECT statement without any LIMIT clause.
Any existing implementations of `SizedIterable` will now require implementation of these 2 new members.
Any custom implementations of the `SizedIterable` interface with a `limit()` override will now show a warning that the declaration overrides
a deprecated member. This override should be split into an implementation of the 2 new members instead.

The original `FunctionProvider.queryLimit()` is also being deprecated in favor of `queryLimitAndOffset()`, which takes a
nullable `size` parameter to allow exclusion of the LIMIT clause. The latter deprecation only affects extensions of the
nullable `size` parameter to allow exclusion of the LIMIT clause. This latter deprecation only affects extensions of the
`FunctionProvider` class when creating a custom `VendorDialect` class.

## 0.54.0
Expand Down
5 changes: 4 additions & 1 deletion exposed-core/api/exposed-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,9 @@ public abstract interface class org/jetbrains/exposed/sql/LazySizedIterable : or

public final class org/jetbrains/exposed/sql/LazySizedIterable$DefaultImpls {
public static fun forUpdate (Lorg/jetbrains/exposed/sql/LazySizedIterable;Lorg/jetbrains/exposed/sql/vendors/ForUpdateOption;)Lorg/jetbrains/exposed/sql/SizedIterable;
public static fun limit (Lorg/jetbrains/exposed/sql/LazySizedIterable;I)Lorg/jetbrains/exposed/sql/SizedIterable;
public static fun notForUpdate (Lorg/jetbrains/exposed/sql/LazySizedIterable;)Lorg/jetbrains/exposed/sql/SizedIterable;
public static fun offset (Lorg/jetbrains/exposed/sql/LazySizedIterable;J)Lorg/jetbrains/exposed/sql/SizedIterable;
}

public final class org/jetbrains/exposed/sql/Lead : org/jetbrains/exposed/sql/WindowFunction {
Expand Down Expand Up @@ -2219,8 +2221,9 @@ public abstract interface class org/jetbrains/exposed/sql/SizedIterable : java/l
public final class org/jetbrains/exposed/sql/SizedIterable$DefaultImpls {
public static fun forUpdate (Lorg/jetbrains/exposed/sql/SizedIterable;Lorg/jetbrains/exposed/sql/vendors/ForUpdateOption;)Lorg/jetbrains/exposed/sql/SizedIterable;
public static synthetic fun forUpdate$default (Lorg/jetbrains/exposed/sql/SizedIterable;Lorg/jetbrains/exposed/sql/vendors/ForUpdateOption;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/SizedIterable;
public static synthetic fun limit$default (Lorg/jetbrains/exposed/sql/SizedIterable;IJILjava/lang/Object;)Lorg/jetbrains/exposed/sql/SizedIterable;
public static fun limit (Lorg/jetbrains/exposed/sql/SizedIterable;I)Lorg/jetbrains/exposed/sql/SizedIterable;
public static fun notForUpdate (Lorg/jetbrains/exposed/sql/SizedIterable;)Lorg/jetbrains/exposed/sql/SizedIterable;
public static fun offset (Lorg/jetbrains/exposed/sql/SizedIterable;J)Lorg/jetbrains/exposed/sql/SizedIterable;
}

public final class org/jetbrains/exposed/sql/Slf4jSqlDebugLogger : org/jetbrains/exposed/sql/SqlLogger {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ interface SizedIterable<out T> : Iterable<T> {
ReplaceWith("limit(n).offset(offset)"),
DeprecationLevel.WARNING
)
fun limit(n: Int, offset: Long = 0): SizedIterable<T>
fun limit(n: Int, offset: Long): SizedIterable<T>

/** Returns a new [SizedIterable] containing only [count] elements. */
fun limit(count: Int): SizedIterable<T>
fun limit(count: Int): SizedIterable<T> = limit(count, 0)

/** Returns a new [SizedIterable] containing only elements starting from the specified [start]. */
fun offset(start: Long): SizedIterable<T>
fun offset(start: Long): SizedIterable<T> = limit(Int.MAX_VALUE, start)

/** Returns the number of elements stored. */
fun count(): Long
Expand Down

0 comments on commit 0d67e47

Please sign in to comment.