docs
This commit is contained in:
parent
bca933a055
commit
1c03a28c8a
@ -226,7 +226,38 @@ where
|
|||||||
TryInsert::from_insert(self)
|
TryInsert::from_insert(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// On conflict do nothing
|
/// Set ON CONFLICT do nothing, but with MySQL specific polyfill.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use sea_orm::{entity::*, query::*, sea_query::OnConflict, tests_cfg::cake, DbBackend};
|
||||||
|
///
|
||||||
|
/// let orange = cake::ActiveModel {
|
||||||
|
/// id: ActiveValue::set(2),
|
||||||
|
/// name: ActiveValue::set("Orange".to_owned()),
|
||||||
|
/// };
|
||||||
|
///
|
||||||
|
/// assert_eq!(
|
||||||
|
/// cake::Entity::insert(orange.clone())
|
||||||
|
/// .on_conflict_do_nothing()
|
||||||
|
/// .build(DbBackend::MySql)
|
||||||
|
/// .to_string(),
|
||||||
|
/// r#"INSERT INTO `cake` (`id`, `name`) VALUES (2, 'Orange') ON DUPLICATE KEY UPDATE `id` = `id`"#,
|
||||||
|
/// );
|
||||||
|
/// assert_eq!(
|
||||||
|
/// cake::Entity::insert(orange.clone())
|
||||||
|
/// .on_conflict_do_nothing()
|
||||||
|
/// .build(DbBackend::Postgres)
|
||||||
|
/// .to_string(),
|
||||||
|
/// r#"INSERT INTO "cake" ("id", "name") VALUES (2, 'Orange') ON CONFLICT ("id") DO NOTHING"#,
|
||||||
|
/// );
|
||||||
|
/// assert_eq!(
|
||||||
|
/// cake::Entity::insert(orange)
|
||||||
|
/// .on_conflict_do_nothing()
|
||||||
|
/// .build(DbBackend::Sqlite)
|
||||||
|
/// .to_string(),
|
||||||
|
/// r#"INSERT INTO "cake" ("id", "name") VALUES (2, 'Orange') ON CONFLICT ("id") DO NOTHING"#,
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
pub fn on_conflict_do_nothing(mut self) -> TryInsert<A>
|
pub fn on_conflict_do_nothing(mut self) -> TryInsert<A>
|
||||||
where
|
where
|
||||||
A: ActiveModelTrait,
|
A: ActiveModelTrait,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user