Add an inclusive variant of the synthetic SEEK clause (>= instead of >)
Use case
seek() / seekAfter() always render a strictly exclusive predicate:
SELECT * FROM t WHERE (id, code) > (3, 'abc') ORDER BY id, codeThere is no way to get the same predicate with >=, i.e. a page that starts at the cursor row rather than after it.
I'm building a keyset-paginated REST API with an optional includeCursorItem flag. The flag exists because of deep-linkable UI state: a user selects a row in a paginated table, the URL is updated to reference that row, and the URL is shared. When the recipient opens it, the table must render the referenced row first, followed by the rest of the page, not just the rows after it. Regular "next page" clicks (or public REST-like API) keep using the exclusive form, so both semantics are needed from the same code path, selected by a boolean.
Possible solution
An inclusive counterpart to the existing methods on SelectSeekStepN, e.g.:
DSL.using(configuration)
.selectFrom(TABLE)
.orderBy(ID, CODE)
.seekAfterInclusive(3, "abc") // or seekInclusive(...)
.fetch();rendering:
SELECT ... FROM table
WHERE (id, code) >= (3, 'abc')
ORDER BY id ASC, code ASCwith the same benefits of seek() - nulls, ordering, whatever.
If adding overloads to every SelectSeekStepN arity is too costly, a flag on the seek step, would already solve the use case.
Possible workarounds
SelectSeekStepN only offers seek(), seekAfter() and the deprecated seekBefore(), all exclusive ranges. So the options today are:
- Query the cursor row separately and
UNION ALLit with an exclusiveseek()page. This means an extra query / more complex plan for what is a one-character difference in SQL. - Drop
seek()and hand-write the predicate, e.g.row(A, B).ge(row(a, b)). This works, but gives up advantages ofseek(), e.g.:ASC/DESCorderings,NULLS FIRST/NULLS LASThandling, and the compile-time check that the cursor tuple degree matches theORDER BYdegree is lost.
jOOQ Version
3.21.7
Database product and version
Postgres 18
Java Version
No response
JDBC / R2DBC driver name and version (include name if unofficial driver)
No response
Source: jOOQ/jOOQ