pub enum IfExists {
Error,
Append,
Truncate,
Skip,
Upsert,
}Expand description
What to do when the target table already exists and is non-empty.
Variants§
Error
Refuse to copy. Pre-flights the target with SELECT 1 ... LIMIT 1
before issuing any source SELECT.
Append
Insert alongside existing rows. UNIQUE/PK conflicts surface as driver errors and abort the run with already-committed batches still present on the target.
Truncate
DELETE FROM <tbl> then insert. Destructive. Wrapped together
with the first batch in a backend-aware transaction so a transient
failure of the first INSERT cannot leave the target wiped + empty.
Skip
Insert rows whose primary key does not yet exist on the target;
silently skip rows whose PK is already present. PG/SQLite use
ON CONFLICT (pk) DO NOTHING, MySQL uses INSERT IGNORE,
MSSQL/Oracle use a MERGE … WHEN NOT MATCHED statement.
Requires conflict columns on the destination table — either via
a declared primary key, or via the --key COL[,COL...]
override. Tables without either raise a hard error.
Upsert
Insert rows whose primary key does not yet exist; update all
non-PK columns when the PK already exists. PG/SQLite use
ON CONFLICT (pk) DO UPDATE SET col = EXCLUDED.col, MySQL
uses INSERT … ON DUPLICATE KEY UPDATE col = VALUES(col),
MSSQL/Oracle use a full MERGE with both branches.
Requires a declared primary key on the destination table; see
Skip for the no-PK behaviour.
Implementations§
Source§impl IfExists
impl IfExists
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parse a strategy name (case-insensitive). Recognised: error,
append, truncate, skip, upsert.
Sourcepub fn resolves_conflicts(self) -> bool
pub fn resolves_conflicts(self) -> bool
True for the two PK-driven conflict-resolution strategies.
Used by run_copy to look up the destination PK once up front
and to force the dispatcher onto the generic INSERT path (the
native bulk loaders carry no conflict semantics).
Trait Implementations§
impl Copy for IfExists
impl Eq for IfExists
impl StructuralPartialEq for IfExists
Auto Trait Implementations§
impl Freeze for IfExists
impl RefUnwindSafe for IfExists
impl Send for IfExists
impl Sync for IfExists
impl Unpin for IfExists
impl UnsafeUnpin for IfExists
impl UnwindSafe for IfExists
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.