pub struct ConflictClause {
pub target: ConflictTarget,
pub action: Option<ConflictAction>,
pub set: Set,
pub where_: Where,
}Expand description
ON CONFLICT [<target>] DO NOTHING | DO UPDATE SET … [WHERE …]
From PostgreSQL 17, https://www.postgresql.org/docs/17/sql-insert.html:
ON CONFLICT [ conflict_target ] conflict_action
conflict_target: ( { index_column_name | ( index_expression ) } [ COLLATE … ] [ opclass ] [, ...] )
[ WHERE index_predicate ]
| ON CONSTRAINT constraint_name
conflict_action: DO NOTHING
| DO UPDATE SET { … } [, ...] [ WHERE condition ]The two halves are easy to conflate and behave nothing alike. The target is
an index inference — which unique index the conflict is detected on — and its
WHERE is the index’s predicate, matched against the index rather than
evaluated per row. The action’s WHERE filters which conflicting rows get
updated. Both are WHEREs in the same clause, and both are reachable through
HasWhere here: on ConflictTarget for the first, on ConflictClause for
the second.
DO UPDATE also requires at least one assignment, which is checked rather than
rendered into a syntax error.
Fields§
§target: ConflictTargetWhich conflicts this handles. Absent means any.
action: Option<ConflictAction>What to do. None is how a default-constructed clause stays absent: there
is no ON CONFLICT without an action.
set: SetThe assignments of DO UPDATE.
where_: WhereWhich conflicting rows DO UPDATE applies to.
Implementations§
Trait Implementations§
Source§impl Clone for ConflictClause
impl Clone for ConflictClause
Source§fn clone(&self) -> ConflictClause
fn clone(&self) -> ConflictClause
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more