OnConflictClauseBuilder

Configurator for the ON CONFLICT clause in an INSERT query.

Functions

Link copied to clipboard
abstract fun doNothing()

In case of conflict, do nothing (DO NOTHING).

Link copied to clipboard
abstract fun doUpdate(vararg setPairs: Pair<String, String>, whereCondition: String? = null)

In case of conflict, perform an update (DO UPDATE) using column-value pairs. This is the preferred way as it's more readable and less error-prone than manually assembling a string. Usage example: doUpdate( "last_login" to "NOW()", "login_attempts" to "EXCLUDED.login_attempts + 1" )

abstract fun doUpdate(setExpression: String, whereCondition: String? = null)

In case of conflict, perform an update (DO UPDATE).

abstract fun doUpdate(setMap: Map<String, String>, whereCondition: String? = null)

In case of conflict, perform an update (DO UPDATE) using a column-value map. Useful when update logic is built dynamically.

Link copied to clipboard
abstract fun onColumns(vararg columns: String)

Defines the conflict target as a list of columns.

Link copied to clipboard
abstract fun onConstraint(constraintName: String)

Defines the conflict target as an existing constraint name.