| 1 |
//! Types and functions related to PG's and Sqlite's `ON CONFLICT` clause |
| 2 |
//! |
| 3 |
//! Upsert is currently supported by diesel for the following database systems: |
| 4 |
//! |
| 5 |
//! * PostgreSQL version 9.5 or newer |
| 6 |
//! * Sqlite3 version 3.24.0 or newer |
| 7 |
//! * MySQL version 5.7 or newer |
| 8 |
//! |
| 9 |
//! See [the methods on `InsertStatement`](crate::query_builder::InsertStatement#impl-2) |
| 10 |
//! for usage examples. |
| 11 |
//! |
| 12 |
//! Constructing an upsert statement from an existing select statement |
| 13 |
//! requires a where clause on sqlite due to a ambiguity in their |
| 14 |
//! parser. See [the corresponding documentation](https://www.sqlite.org/lang_UPSERT.html) |
| 15 |
//! for details. |
| 16 |
use crate::query_builder::upsert::on_conflict_actions::Excluded; |
| 17 |
|
| 18 |
mod on_conflict_extension; |
| 19 |
|
| 20 |
pub use self::on_conflict_extension::DecoratableTarget; |
| 21 |
pub use self::on_conflict_extension::*; |
| 22 |
#[cfg(feature = "postgres_backend")] |
| 23 |
pub use crate::pg::query_builder::on_constraint::*; |
| 24 |
|
| 25 |
/// Represents `excluded.column` in an `ON CONFLICT DO UPDATE` clause. |
| 26 |
pub fn excluded<T>(excluded: T) -> Excluded<T> { |
| 27 |
Excluded::new(excluded) |
| 28 |
} |