diff --git a/lib/src/sql/statements/insert.rs b/lib/src/sql/statements/insert.rs index 42574da3..0d0287ce 100644 --- a/lib/src/sql/statements/insert.rs +++ b/lib/src/sql/statements/insert.rs @@ -127,6 +127,9 @@ impl fmt::Display for InsertStatement { f.write_str(" IGNORE")? } write!(f, " INTO {} {}", self.into, self.data)?; + if let Some(ref v) = self.update { + write!(f, " {v}")? + } if let Some(ref v) = self.output { write!(f, " {v}")? } @@ -189,4 +192,13 @@ mod tests { let out = res.unwrap().1; assert_eq!("INSERT IGNORE INTO test (field) VALUES ($value)", format!("{}", out)) } + + #[test] + fn insert_statement_ignore_update() { + let sql = "INSERT IGNORE INTO test (field) VALUES ($value) ON DUPLICATE KEY UPDATE field = $value"; + let res = insert(sql); + assert!(res.is_ok()); + let out = res.unwrap().1; + assert_eq!("INSERT IGNORE INTO test (field) VALUES ($value) ON DUPLICATE KEY UPDATE field = $value", format!("{}", out)) + } }