add Target where clause for on conflict

This commit is contained in:
Vitaliy Shein 2021-06-04 20:49:28 +03:00
parent cf079b8b7d
commit 96f48fc5e4

View File

@ -3,6 +3,7 @@ package clause
type OnConflict struct {
Columns []Column
Where Where
TargetWhere Where
OnConstraint string
DoNothing bool
DoUpdates Set
@ -26,6 +27,12 @@ func (onConflict OnConflict) Build(builder Builder) {
builder.WriteString(`) `)
}
if len(onConflict.TargetWhere.Exprs) > 0 {
builder.WriteString(" WHERE ")
onConflict.TargetWhere.Build(builder)
builder.WriteByte(' ')
}
if onConflict.OnConstraint != "" {
builder.WriteString("ON CONSTRAINT ")
builder.WriteString(onConflict.OnConstraint)