Upsert
Builders for SQLite/PostgreSQL upsert Frags.
Every produced Frag follows the invariant parts.length == params.length + 1 and is rendered via dialect.paramPlaceholder (both dialects use ?). Identifiers are validated through SqlIdentifier.validate and quoted with double quotes in the conflict clause. Assignment columns are additionally validated against Table.columns.
Attributes
- Source
- Upsert.scala
- Graph
-
- Supertypes
- Self type
-
Upsert.type
Members list
Value members
Concrete methods
Alias used by prior docs.
Alias used by prior docs.
Low-level builder: full INSERT with DO NOTHING.
Low-level builder: full INSERT with DO NOTHING.
Value parameters
- columns
-
column names in order, each validated
- conflictColumn
-
validated and quoted in suffix
- tableName
-
validated via SqlIdentifier
- values
-
values aligned with columns
Attributes
- Source
- Upsert.scala
Overload accepting comma-joined column string (as Repo does).
Suffix ON CONFLICT ("col") DO NOTHING.
Low-level builder: full INSERT with DO UPDATE SET.
Suffix ON CONFLICT ("conflict") DO UPDATE SET "col" = ?, .... Assignments must be non-empty; each column is validated and quoted.
Suffix ON CONFLICT ("conflict") DO UPDATE SET "col" = ?, .... Assignments must be non-empty; each column is validated and quoted.
Attributes
- Source
- Upsert.scala
INSERT ... ON CONFLICT ("conflict") DO NOTHING for an entity.
INSERT ... ON CONFLICT ("conflict") DO NOTHING for an entity.
Builds INSERT INTO "table" ("cols") VALUES (?, ...) ON CONFLICT ("conflict") DO NOTHING. The table name is validated via SqlIdentifier.validate and the conflict column is validated as an identifier and checked for membership in table.columns.
Value parameters
- conflictColumn
-
validated identifier that must be present in
table.columns - entity
-
entity whose values are obtained via
table.codec.toDbValues - table
-
validated via Table; its name via SqlIdentifier.validate and its columns used for conflict validation
Attributes
- Returns
-
a Frag whose SQL is
INSERT ... ON CONFLICT ("conflict") DO NOTHINGwith a quotedINSERT INTO "table" ("cols")head - Throws
-
IllegalArgumentException
if
conflictColumnis not a valid identifier or is not found intable.columns - Source
- Upsert.scala
INSERT ... ON CONFLICT ("conflict") DO UPDATE SET ... for an entity.
INSERT ... ON CONFLICT ("conflict") DO UPDATE SET ... for an entity.
Updates all columns except the conflict column. The conflict column is validated via SqlIdentifier.validate and must exist in table.columns. The update set is derived as table.columns.filter(_ != conflict) and validated against Table.columns.
Value parameters
- conflictColumn
-
validated identifier that must be present in
table.columns - entity
-
entity serialized via
table.codec.toDbValues - table
-
validated via Table; name validated via SqlIdentifier.validate
Attributes
- Returns
-
a Frag with
ON CONFLICT ("conflict") DO UPDATE SET "col" = ?, ...where cols are all table columns except the conflict column - Throws
-
IllegalArgumentException
if
conflictColumnis invalid or not intable.columns, or if the table has only the conflict column (no assignable columns to update) - Source
- Upsert.scala
INSERT ... ON CONFLICT ("conflict") DO UPDATE SET "col" = ?, ... for an entity with explicit update columns.
INSERT ... ON CONFLICT ("conflict") DO UPDATE SET "col" = ?, ... for an entity with explicit update columns.
All identifiers are validated via SqlIdentifier.validate. The conflict column and each updateColumns entry must exist in table.columns.
Value parameters
- conflictColumn
-
validated identifier that must be present in
table.columns - entity
-
entity serialized via
table.codec.toDbValues - table
-
validated via Table; name validated via SqlIdentifier.validate
- updateColumns
-
validated against
table.columns; each entry validated as an identifier, must exist in the table, must not containconflictColumn, and must be non-empty
Attributes
- Returns
-
a Frag with
ON CONFLICT ("conflict") DO UPDATE SETfor the specified columns - Throws
-
IllegalArgumentException
if any identifier is invalid, if any column is not in
table.columns, ifupdateColumnscontains the conflict column or contains duplicates, or if it is empty - Source
- Upsert.scala