Function diesel::insert_or_ignore_into

source ·
pub fn insert_or_ignore_into<T: Table>(
    target: T
) -> IncompleteInsertOrIgnoreStatement<T>
Expand description

Creates an INSERT [OR] IGNORE statement.

If a constraint violation fails, the database will ignore the offending row and continue processing any subsequent rows. This function is only available with MySQL and SQLite.

With PostgreSQL, similar functionality is provided by on_conflict_do_nothing.


    .values((id.eq(1), name.eq("Jim")))

        (id.eq(1), name.eq("Sean")),
        (id.eq(2), name.eq("Tess")),

let names =<String>(connection)?;
assert_eq!(vec![String::from("Jim"), String::from("Tess")], names);