Add OnConflict OnConstraint support, close #3882

This commit is contained in:
Jinzhu 2021-01-05 21:31:51 +08:00
parent 6d260a86bd
commit 435bf70865
1 changed files with 12 additions and 5 deletions

View File

@ -1,11 +1,12 @@
package clause
type OnConflict struct {
Columns []Column
Where Where
DoNothing bool
DoUpdates Set
UpdateAll bool
Columns []Column
Where Where
OnConstraint string
DoNothing bool
DoUpdates Set
UpdateAll bool
}
func (OnConflict) Name() string {
@ -31,6 +32,12 @@ func (onConflict OnConflict) Build(builder Builder) {
builder.WriteByte(' ')
}
if onConflict.OnConstraint != "" {
builder.WriteString("ON CONSTRAINT ")
builder.WriteString(onConflict.OnConstraint)
builder.WriteByte(' ')
}
if onConflict.DoNothing {
builder.WriteString("DO NOTHING")
} else {