1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use ;
use cratestmt;
/// Executes a lowered single-row upsert on a non-SQL database driver.
///
/// The query engine emits this operation only after verifying the requested
/// target and branch behavior against [`Capability`](crate::driver::Capability).
/// [`stmt`](Self::stmt) contains one values row and an
/// [`stmt::Upsert`](crate::stmt::Upsert) clause whose target has been lowered
/// from model fields to database columns. Shared mutations retain their
/// model-declared field defaults so the driver can apply the same value
/// when it creates an item.
///
/// A driver must perform the conflict check and the create, update, or ignore
/// action atomically. It must not implement this operation as a read followed
/// by a separate insert or update. An update action returns the stored row. An
/// ignore action returns one row after an insert and zero rows after the
/// selected target conflicts.
///
/// # Examples
///
/// ```ignore
/// use toasty_core::driver::operation::{Operation, Upsert};
///
/// let op = Upsert {
/// stmt: lowered_insert,
/// params: typed_params,
/// ret: Some(return_types),
/// };
/// let operation: Operation = op.into();
/// ```