Package-level declarations

Types

Link copied to clipboard
internal class CteClause

The WITH clause every builder carries. A field rather than a base class, so with and recursive return each builder's own type.

Link copied to clipboard
class DeleteQuery @PublishedApi constructor(provider: SessionProvider, table: String) : RunnableQuery<DeleteQuery>

A DELETE under construction. A WHERE is required; emptying a table is written with rawQuery.

Link copied to clipboard
class InsertQuery @PublishedApi constructor(provider: SessionProvider, table: String) : RunnableQuery<InsertQuery>

An INSERT under construction. value and values declare a column together with its @name placeholder in VALUES, so the two lists cannot drift; valueExpression puts SQL there instead - now(), DEFAULT, a subselect. The values are supplied at the terminal.

Link copied to clipboard
class OnConflictClause @PublishedApi constructor

The ON CONFLICT clause of an InsertQuery, configured inside InsertQuery.onConflict. The target is optional; an action is required.

Link copied to clipboard

Which value an identity column takes where an INSERT supplies one: OVERRIDING SYSTEM VALUE or OVERRIDING USER VALUE.

Link copied to clipboard
class QueryFragment(val sql: String, val params: Map<String, Any?> = emptyMap())

A piece of SQL and the parameters it names, kept together so that a WHERE assembled at runtime cannot name a parameter nobody supplied. join combines them.

Link copied to clipboard
class RawQuery @PublishedApi constructor(provider: SessionProvider, sql: String) : RunnableQuery<RawQuery>

SQL written by hand, with @name parameters and the terminals every builder has, for a statement better written whole. Its SQL comes back out of toSql.

Link copied to clipboard
class ResultQuery @PublishedApi constructor(val query: RunnableQuery<*>)

The same query with every terminal returning a DataResult instead of throwing, as if wrapped in dbResult. Reached by RunnableQuery.asResult.

Link copied to clipboard
abstract class RunnableQuery<T : RunnableQuery<T>> @PublishedApi constructor(val queryProvider: SessionProvider)

A query that can be run: the base of every builder and of RawQuery, carrying the terminal methods.

Link copied to clipboard
class SelectQuery @PublishedApi constructor(provider: SessionProvider, selectClause: String) : RunnableQuery<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.

Link copied to clipboard
class UpdateQuery @PublishedApi constructor(provider: SessionProvider, table: String) : RunnableQuery<UpdateQuery>

An UPDATE under construction. setValue and setValues assign from @name parameters supplied at the terminal; setExpression assigns SQL, which may read the column: setExpression("quantity", "quantity - 1").

Functions

Link copied to clipboard
internal fun StringBuilder.appendClause(keyword: String, body: String?)

Appends a clause where its body carries anything, so where(null) and where("") leave no WHERE.

Link copied to clipboard
fun List<QueryFragment>.join(separator: String, prefix: String = "", postfix: String = "", addParenthesis: Boolean = true): QueryFragment

Joins the fragments that carry anything, merging their parameters. Joining none gives an empty fragment, without prefix and postfix, which a clause leaves out.

Link copied to clipboard
internal inline fun requireBuildable(value: Boolean, message: () -> String)

Refuses a query the builder cannot render, naming what is missing, as INVALID_ARGUMENT - which the result style throws rather than returns.

Link copied to clipboard

Pairs this SQL with one parameter it names, given without the leading @.

Link copied to clipboard
infix fun String.withParams(params: Map<String, Any?>): QueryFragment

Pairs this SQL with the parameters it names, given without the leading @.