Function diesel::sqlite::query_builder::functions::insert_or_replace
[−]
[src]
pub fn insert_or_replace<T: ?Sized>(records: &T)
-> IncompleteInsertStatement<&T, Or<Insert, Replace>>
Creates a SQLite INSERT OR REPLACE
statement. If a constraint violation
fails, SQLite will attempt to replace the offending row instead.
Example
insert(&NewUser::new("Sean")).into(users).execute(&conn).unwrap(); insert(&NewUser::new("Tess")).into(users).execute(&conn).unwrap(); let new_user = User { id: 1, name: "Jim" }; insert_or_replace(&new_user).into(users).execute(&conn).unwrap(); let names = users.select(name).order(id).load::<String>(&conn); assert_eq!(Ok(vec!["Jim".into(), "Tess".into()]), names);