pub struct OnConflictBuilder<'a, S, T> { /* private fields */ }Expand description
Intermediate builder for typed ON CONFLICT clause construction (PostgreSQL).
Created by InsertBuilder::on_conflict() or
InsertBuilder::on_conflict_on_constraint().
Call do_nothing() or do_update()
to complete the clause.
Implementations§
Source§impl<'a, S, T> OnConflictBuilder<'a, S, T>
impl<'a, S, T> OnConflictBuilder<'a, S, T>
Sourcepub fn where<E>(self, condition: E) -> Self
pub fn where<E>(self, condition: E) -> Self
Adds a WHERE clause to the conflict target for partial index matching.
Generates: ON CONFLICT (col) WHERE condition DO ...
Note: WHERE is only meaningful for column-based targets, not for
ON CONFLICT ON CONSTRAINT targets.
Sourcepub fn do_nothing(self) -> InsertBuilder<'a, S, InsertOnConflictSet, T>
pub fn do_nothing(self) -> InsertBuilder<'a, S, InsertOnConflictSet, T>
Resolves the conflict by doing nothing (ignoring the conflicting row).
Generates: ON CONFLICT (col1, col2) DO NOTHING
Sourcepub fn do_update(
self,
set: impl ToSQL<'a, PostgresValue<'a>>,
) -> InsertBuilder<'a, S, InsertDoUpdateSet, T>
pub fn do_update( self, set: impl ToSQL<'a, PostgresValue<'a>>, ) -> InsertBuilder<'a, S, InsertDoUpdateSet, T>
Resolves the conflict by updating the existing row.
The set parameter accepts any ToSQL value, typically an UpdateModel
which generates the SET clause assignments. Use EXCLUDED.column to
reference the proposed insert values.
Generates: ON CONFLICT (col1, col2) DO UPDATE SET ...
Chain .r#where(condition) to add a conditional update filter.