Add ON DUPLICATE KEY UPDATE support (MySQL).

This commit is contained in:
go-jet 2020-05-03 20:46:21 +02:00
parent 30284af33e
commit 980b9b6aac
18 changed files with 388 additions and 109 deletions

View file

@ -518,7 +518,7 @@ type SetPair struct {
}
// SetClause clause
type SetClause []SetPair
type SetClause []ColumnAssigment
// Serialize for SetClause
func (s SetClause) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
@ -526,16 +526,15 @@ func (s SetClause) Serialize(statementType StatementType, out *SQLBuilder, optio
out.WriteString("SET")
out.IncreaseIdent(4)
for i, pair := range s {
for i, assigment := range s {
if i > 0 {
out.WriteString(",")
out.NewLine()
}
pair.Column.serialize(statementType, out, ShortName.WithFallTrough(options)...)
out.WriteString("=")
pair.Value.serialize(statementType, out, FallTrough(options)...)
assigment.serialize(statementType, out, FallTrough(options)...)
}
out.DecreaseIdent(4)
}