Repository: diesel-rs/diesel
File: diesel/src/upsert/on_conflict_extension.rs (Rust)

Code before:
}

/// A partially constructed `ON CONFLICT` clause.
#[derive(Debug, Clone, Copy)]
pub struct IncompleteOnConflict<Stmt, Target> {
    stmt: Stmt,
    target: Target,
}

impl<T: QuerySource, U, Op, Ret, Target>
    IncompleteOnConflict<InsertStatement<T, U, Op, Ret>, Target>
{
    /// Creates a query with `ON CONFLICT (target) DO NOTHING`
    ///
    /// If you want to do nothing when *any* constraint conflicts, use
    /// [`on_conflict_do_nothing`] instead. See [`on_conflict`] for usage
    /// examples.
    ///
    /// [`on_conflict_do_nothing`]: crate::query_builder::InsertStatement::on_conflict_do_nothing()
    /// [`on_conflict`]: crate::query_builder::InsertStatement::on_conflict()
    pub fn do_nothing(
        self,
    ) -> InsertStatement<T, OnConflictValues<U, Target, DoNothing, NoWhereClause>, Op, Ret> {
        let target = self.target;
        self.stmt.replace_values(|values| {
            OnConflictValues::new(values, target, DoNothing, NoWhereClause {})
        })
    }
}

impl<Stmt, Target> IncompleteOnConflict<Stmt, Target> {
    /// Used to create a query in the form `ON CONFLICT (...) DO UPDATE ... [WHERE ...]`
    ///
    /// Call `.set` on the result of this function with the changes you want to
    /// apply. The argument to `set` can be anything that implements `AsChangeset`
    /// (e.g. anything you could pass to `set` on a normal update statement).
    ///
    /// Note: When inserting more than one row at a time, this query can still fail
    /// if the rows being inserted conflict with each other.
    ///
    /// Some backends (PostgreSQL) support `WHERE` clause is used to limit the rows actually updated.
    /// For PostgreSQL you can use the `.filter()` method to add conditions like this.
    ///
    /// # Examples
    ///
    /// ## Set specific value on conflict
    ///
    /// ```rust
    /// # include!("on_conflict_docs_setup.rs");
    /// #
    /// # #[cfg(any(feature = "sqlite", feature = "postgres"))]

Review comment (suggestion):
```suggestion
            OnConflictValues::new(values, target, DoNothing, NoWhereClause)
```

Code after:
pub struct IncompleteOnConflict<Stmt, Target> {
    stmt: Stmt,
    target: Target,
}

impl<T: QuerySource, U, Op, Ret, Target>
    IncompleteOnConflict<InsertStatement<T, U, Op, Ret>, Target>
{
    /// Creates a query with `ON CONFLICT (target) DO NOTHING`
    ///
    /// If you want to do nothing when *any* constraint conflicts, use
    /// [`on_conflict_do_nothing`] instead. See [`on_conflict`] for usage
    /// examples.
    ///
    /// [`on_conflict_do_nothing`]: crate::query_builder::InsertStatement::on_conflict_do_nothing()
    /// [`on_conflict`]: crate::query_builder::InsertStatement::on_conflict()
    pub fn do_nothing(self) -> InsertStatement<T, OnConflictValues<U, Target, DoNothing>, Op, Ret> {
        let target = self.target;
        self.stmt.replace_values(|values| {
            OnConflictValues::new(values, target, DoNothing, NoWhereClause)
        })
    }
}

impl<Stmt, Target> IncompleteOnConflict<Stmt, Target> {
    /// Used to create a query in the form `ON CONFLICT (...) DO UPDATE ... [WHERE ...]`
    ///
    /// Call `.set` on the result of this function with the changes you want to
    /// apply. The argument to `set` can be anything that implements `AsChangeset`
    /// (e.g. anything you could pass to `set` on a normal update statement).
    ///
    /// Note: When inserting more than one row at a time, this query can still fail
    /// if the rows being inserted conflict with each other.
    ///
    /// Some backends (PostgreSQL) support `WHERE` clause is used to limit the rows actually updated.
    /// For PostgreSQL you can use the `.filter()` method to add conditions like this.
    ///
    /// # Examples
    ///
    /// ## Set specific value on conflict
    ///
    /// ```rust
    /// # include!("on_conflict_docs_setup.rs");
    /// #
    /// # #[cfg(any(feature = "sqlite", feature = "postgres"))]
    /// # fn main() {
    /// #     use self::users::dsl::*;
    /// #     let conn = &mut establish_connection();
    /// #     #[cfg(feature = "postgres")]
    /// #     diesel::sql_query("TRUNCATE TABLE users").execute(conn).unwrap();
    /// #     #[cfg(feature = "sqlite")]