SelectQuery
A SELECT under construction. Every clause takes SQL and passes it through; the builder supplies the keywords and their order, and leaves out a clause given null or blank, so a filter assembled at runtime can go straight in.
val senators = db.select("id", "cognomen", "province_id")
.from("senate")
.where(filter.sql) // null or empty leaves out the WHERE entirely
.orderBy("cognomen")
.page(page = 0, size = 20)
.fetchObjects<Senator>(filter.params)Properties
Functions
This query with terminals that return a DataResult instead of throwing, on the boundary dbResult applies - a fetch*Strict that found no row still throws.
Turns this query into a step of a TransactionPlan instead of running it. The parameters given at the step's terminal may hold TransactionValues pointing at earlier steps.
Returns an independent copy, so that variants can be built from a shared base.
Carries registered converters into a builder's copy(), alongside whatever clauses it copies.
Runs the statement and returns how many rows it affected.
As fetchField, but the query must return exactly one row rather than at most one.
Runs the query and returns its single row, throwing where the count was anything but one.
Runs the query and hands the first column of each row, as T, to block as forEachRow does.
Runs the query and hands each row, mapped onto T, to block as it arrives, as forEachRow does.
Sets the FROM clause, passed through as written: "legions l JOIN provinces p ON l.province_id = p.id", "UNNEST(@ids) AS id", "calculate_tribute(@province, @year)".
Sets the FROM clause to a subquery, parenthesised and optionally aliased.
Sets the GROUP BY columns. null or blank leaves the clause out.
Sets the HAVING condition, which requires a GROUP BY. null or blank leaves the clause out.
Sets LIMIT. null leaves it out.
Sets the locking clause, FOR included, since several may follow one another: "FOR UPDATE", "FOR UPDATE OF l FOR SHARE OF p NOWAIT". null or blank leaves it out. Outside a transaction the lock ends with the statement.
Sets OFFSET. null leaves it out, as does 0.
Sets the ORDER BY clause. null or blank leaves the clause out.
The driver query every terminal runs, carrying this query's own converters.
Marks the WITH clause RECURSIVE.
Registers a ParameterConverter for this query alone, on the terms of registerResultConverter.
Registers a ResultConverter for this query alone, consulted ahead of the session's. A later registration here wins over an earlier one.
A query counting the rows this one matches across every page, for the total a paged list shows.
Sets the WHERE condition. null or blank leaves the clause out.
Sets the WINDOW clause, as SQL: the named windows the select list and ORDER BY refer to, "w AS (PARTITION BY province ORDER BY strength DESC)". null or blank leaves the clause out.
Adds a common table expression. Call it more than once for more than one.