Fix OnConflict where order for postgres, close #4073

This commit is contained in:
Jinzhu 2021-02-10 14:11:29 +08:00
parent 84ea3ec0cc
commit a13b7a6acb
1 changed files with 6 additions and 6 deletions

View File

@ -26,12 +26,6 @@ func (onConflict OnConflict) Build(builder Builder) {
builder.WriteString(`) `) builder.WriteString(`) `)
} }
if len(onConflict.Where.Exprs) > 0 {
builder.WriteString("WHERE ")
onConflict.Where.Build(builder)
builder.WriteByte(' ')
}
if onConflict.OnConstraint != "" { if onConflict.OnConstraint != "" {
builder.WriteString("ON CONSTRAINT ") builder.WriteString("ON CONSTRAINT ")
builder.WriteString(onConflict.OnConstraint) builder.WriteString(onConflict.OnConstraint)
@ -44,6 +38,12 @@ func (onConflict OnConflict) Build(builder Builder) {
builder.WriteString("DO UPDATE SET ") builder.WriteString("DO UPDATE SET ")
onConflict.DoUpdates.Build(builder) onConflict.DoUpdates.Build(builder)
} }
if len(onConflict.Where.Exprs) > 0 {
builder.WriteString("WHERE ")
onConflict.Where.Build(builder)
builder.WriteByte(' ')
}
} }
// MergeClause merge onConflict clauses // MergeClause merge onConflict clauses