| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rel8.Internal.Statement.OnConflict
Synopsis
- data OnConflict exprs
- data Conflict exprs
- = OnConstraint String
- | OnIndex (Index exprs)
- data Index exprs where
- data Upsert exprs where
- ppOnConflict :: Selects names exprs => TableSchema names -> OnConflict exprs -> Doc
Documentation
data OnConflict exprs Source #
OnConflict represents the ON CONFLICT clause of an INSERT
statement. This specifies what ought to happen when one or more of the
rows proposed for insertion conflict with an existing row in the table.
Constructors
| Abort | Abort the transaction if there are conflicting rows (Postgres' default) |
| DoNothing (Maybe (Conflict exprs)) |
|
| DoUpdate (Upsert exprs) | ON CONFLICT (...) DO UPDATE ... |
Represents what PostgreSQL calls a
conflict_target
in an ON CONFLICT clause of an INSERT statement.
Constructors
| OnConstraint String | Use a specific named constraint for the conflict target. This
corresponds the the syntax |
| OnIndex (Index exprs) | Have PostgreSQL perform what it calls _unique index inference_ by giving it a description of the target index. |
data Index exprs where Source #
A description of the target unique index — its columns (and/or expressions) and, in the case of partial indexes, a predicate.
data Upsert exprs where Source #
The ON CONFLICT (...) DO UPDATE clause of an INSERT statement, also
known as "upsert".
When an existing row conflicts with a row proposed for insertion,
ON CONFLICT DO UPDATE allows you to instead update this existing row. The
conflicting row proposed for insertion is then "excluded", but its values
can still be referenced from the SET and WHERE clauses of the UPDATE
statement.
Upsert in Postgres a "conflict target" to be specified — this is the
UNIQUE index from conflicts with which we would like to recover. Indexes
are specified by listing the columns that comprise them along with an
optional predicate in the case of partial indexes.
Constructors
| Upsert | |
ppOnConflict :: Selects names exprs => TableSchema names -> OnConflict exprs -> Doc Source #