Fix upsert for mysql
This commit is contained in:
parent
b869d2be8b
commit
4a9e7a1b1a
1 changed files with 11 additions and 0 deletions
|
@ -190,6 +190,17 @@ func BuildUpsertQueryMySQL(dia Dialect, tableName string, update, whitelist []st
|
|||
buf := strmangle.GetBuffer()
|
||||
defer strmangle.PutBuffer(buf)
|
||||
|
||||
if len(update) == 0 {
|
||||
fmt.Fprintf(
|
||||
buf,
|
||||
"INSERT IGNORE INTO %s (%s) VALUES (%s)",
|
||||
tableName,
|
||||
strings.Join(whitelist, ", "),
|
||||
strmangle.Placeholders(dia.IndexPlaceholders, len(whitelist), 1, 1),
|
||||
)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
fmt.Fprintf(
|
||||
buf,
|
||||
"INSERT INTO %s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE ",
|
||||
|
|
Loading…
Reference in a new issue