Ensure ON DUPLICATE KEY UPDATE
clause is displayed on INSERT
statement (#2474)
This commit is contained in:
parent
c2e695b897
commit
b350f052a7
1 changed files with 12 additions and 0 deletions
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue