UpdateQuery
An UPDATE under construction.
Columns are declared the same way as in an InsertQuery: setValue and setValues put a @name placeholder on the right of the assignment, and the values are supplied at the terminal. setExpression puts SQL there instead, which is what an increment needs - setExpression("quantity", "quantity - 1") reads the column it is assigning.
A WHERE is required. An UPDATE over a whole table is a statement worth having to mean, and this builder is not where you mean it: write it as OctaviusClient.rawQuery and it is obvious to whoever reads the diff.
db.update("legion_supplies")
.setExpression("quantity", "quantity - @taken")
.setValue("last_drawn_at")
.where("id = @id")
.update("taken" to 1, "last_drawn_at" to now, "id" to supplyId)Properties
Functions
Switches this query to the result style: every terminal on the returned object hands back a DataResult instead of throwing.
Turns this query into a step of a TransactionPlan instead of something to run now.
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.
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.
Sets the FROM clause, for an update that reads from other tables.
Builds the driver query a terminal is about to run, with this query's own converters on it.
Marks the WITH clause RECURSIVE.
Registers a ParameterConverter for this query and nothing else.
Registers a ResultConverter for this query and nothing else.
Adds a RETURNING clause, which turns this into a query the fetch* family can read.
Assigns one column from a SQL expression, which may read the column it is assigning.
As setExpression, for several columns at once.
Assigns one column from the @column parameter.
Assigns each column from the parameter of the same name.
Assigns the columns named by a map's keys, each from the parameter of the same name.
Sets the WHERE condition. Required.
Adds a common table expression. Call it more than once for more than one.