InsertQueryBuilder
Defines the public API for building SQL INSERT queries.
Functions
Converts this builder to a StepBuilder that enables lazy execution within a transaction. Returns a wrapper with terminal methods that create TransactionStep instead of executing the query.
Switches the builder to streaming mode, optimal for large datasets. Requires using streaming-specific terminal methods like forEachRow(). REQUIRES ACTIVE TRANSACTION. This method must be called inside a DataAccess.transaction { ... } block. Otherwise, PostgreSQL will ignore fetchSize and load everything into RAM.
Switches the builder to asynchronous mode. Requires providing a CoroutineScope in which operations will be launched.
Explicitly defines the columns for the INSERT statement.
Creates and returns a deep copy of this builder. Returns the concrete builder type (e.g., SelectQueryBuilder), maintaining API fluency.
Defines a SELECT query as the data source for insertion.
Configures behavior in case of key conflict (ON CONFLICT clause).
Marks the WITH clause as recursive.
Adds a RETURNING clause. Requires using .toList(), .toSingle(), etc. instead of .execute().
Fetches a single value from the first column of the first row. Always returns Failure if no rows are found, regardless of nullability. Nullability only controls whether a null value in the column is allowed: use toFieldStrict<Int>() to fail on null, or toFieldStrict<Int?>() to allow null values.
Maps results to a list of objects of the given type. Requires that column names/aliases in SQL (in snake_case convention) match property names in the target class (in camelCase convention) or have a @MapKey annotation with the stored column name.
Convenient inline extension function for toListOf. Uses reified to automatically infer the target type.
Maps the result to a single object of the given type. Works on the same mapping principle as toListOf. Nullability is determined by the KType: use toSingleOf<User>() for non-null or toSingleOf<User?>() for nullable results.
Convenient inline extension function for toSingleOf. Uses reified to automatically infer the target type.
Fetches a single row as Map
Defines a single value, automatically generating a placeholder.
Defines a single value to insert as an SQL expression.
Defines values to insert, automatically generating placeholders in ":value" format for each value in the list.
Defines values to insert, automatically generating placeholders. This is the preferred, high-level method for inserting data. Values from the map must be passed in the terminal method (e.g., .execute()).
Defines values to insert as SQL expressions or placeholders. This is a low-level method.
Adds a Common Table Expression (CTE) to the query.