mirror of https://github.com/go-gorm/gorm.git
add Target where clause for on conflict (#4442)
Co-authored-by: Vitaliy Shein <vitaliy.shein@thebricks.com>
This commit is contained in:
parent
cf079b8b7d
commit
dd8bf88eb9
|
@ -3,6 +3,7 @@ package clause
|
||||||
type OnConflict struct {
|
type OnConflict struct {
|
||||||
Columns []Column
|
Columns []Column
|
||||||
Where Where
|
Where Where
|
||||||
|
TargetWhere Where
|
||||||
OnConstraint string
|
OnConstraint string
|
||||||
DoNothing bool
|
DoNothing bool
|
||||||
DoUpdates Set
|
DoUpdates Set
|
||||||
|
@ -26,6 +27,12 @@ func (onConflict OnConflict) Build(builder Builder) {
|
||||||
builder.WriteString(`) `)
|
builder.WriteString(`) `)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(onConflict.TargetWhere.Exprs) > 0 {
|
||||||
|
builder.WriteString(" WHERE ")
|
||||||
|
onConflict.TargetWhere.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)
|
||||||
|
|
Loading…
Reference in New Issue