SQLProvider

OnConflict Type

What an insert does when the row would break a primary key or a unique constraint or index.

Set on each row before SubmitUpdates; rows of one submit may differ. Databases without an upsert (SQL Server, Oracle, Firebird, ODBC, MS Access) ignore Update and DoNothing and refuse DoNothingOn and UpdateOn. A row inserted without its key reads the key the database gave it; after a conflict it reads the existing row's key when that row was updated, and none when it was left as it was.

Union cases

Union case Description

DoNothing

Full Usage: DoNothing

The existing row stays as it is, whichever unique constraint the new row breaks.

PostgreSQL and DuckDB: ON CONFLICT DO NOTHING; MySQL: ON DUPLICATE KEY UPDATE of nothing; SQLite: INSERT OR IGNORE.

DoNothingOn conflictColumns

Full Usage: DoNothingOn conflictColumns

Parameters:
    conflictColumns : string list - The constraint's or index's columns, as the table has them (matched ignoring case); a partial index can't be named, so use DoNothing for one. A column named twice is refused.

The existing row stays as it is when the new row breaks the unique constraint or index on exactly these columns: ON CONFLICT (columns) DO NOTHING.

PostgreSQL, SQLite 3.24+ and DuckDB; MySQL refuses it.

conflictColumns : string list

The constraint's or index's columns, as the table has them (matched ignoring case); a partial index can't be named, so use DoNothing for one. A column named twice is refused.

Throw

Full Usage: Throw

The insert fails with the database's error (the default).

Update

Full Usage: Update

The existing row gets every column the new row sets.

PostgreSQL: ON CONFLICT (primary key) DO UPDATE; DuckDB the same; MySQL: ON DUPLICATE KEY UPDATE; SQLite: INSERT OR REPLACE, which deletes the existing row and inserts the new one, so columns not set get their defaults and delete triggers and cascades run.

UpdateOn(onColumns, updates)

Full Usage: UpdateOn(onColumns, updates)

Parameters:
    onColumns : string list - The constraint's or index's columns, as the table has them (matched ignoring case).
    updates : ConflictUpdate list - What each named column becomes: the inserted value or a constant (null clears the column). The columns not named keep their old values; a column named twice is refused.

The existing row changes when the new row breaks the unique constraint or index on exactly onColumns: ON CONFLICT (onColumns) DO UPDATE SET a = EXCLUDED.a, b = @value.

PostgreSQL, SQLite 3.24+ and DuckDB; MySQL refuses it.

onColumns : string list

The constraint's or index's columns, as the table has them (matched ignoring case).

updates : ConflictUpdate list

What each named column becomes: the inserted value or a constant (null clears the column). The columns not named keep their old values; a column named twice is refused.

Instance members

Instance member Description

this.IsDoNothing

Full Usage: this.IsDoNothing

Returns: bool
Returns: bool

this.IsDoNothingOn

Full Usage: this.IsDoNothingOn

Returns: bool
Returns: bool

this.IsThrow

Full Usage: this.IsThrow

Returns: bool
Returns: bool

this.IsUpdate

Full Usage: this.IsUpdate

Returns: bool
Returns: bool

this.IsUpdateOn

Full Usage: this.IsUpdateOn

Returns: bool
Returns: bool

Type something to start searching.