Source File
on_conflict.go
Belonging Package
gorm.io/gorm/clause
package clause
type OnConflict struct {
Columns []Column
Where Where
TargetWhere Where
OnConstraint string
DoNothing bool
DoUpdates Set
UpdateAll bool
}
func (OnConflict) () string {
return "ON CONFLICT"
}
// Build build onConflict clause
func ( OnConflict) ( Builder) {
if .OnConstraint != "" {
.WriteString("ON CONSTRAINT ")
.WriteString(.OnConstraint)
.WriteByte(' ')
} else {
if len(.Columns) > 0 {
.WriteByte('(')
for , := range .Columns {
if > 0 {
.WriteByte(',')
}
.WriteQuoted()
}
.WriteString(`) `)
}
if len(.TargetWhere.Exprs) > 0 {
.WriteString(" WHERE ")
.TargetWhere.Build()
.WriteByte(' ')
}
}
if .DoNothing {
.WriteString("DO NOTHING")
} else {
.WriteString("DO UPDATE SET ")
.DoUpdates.Build()
}
if len(.Where.Exprs) > 0 {
.WriteString(" WHERE ")
.Where.Build()
.WriteByte(' ')
}
}
// MergeClause merge onConflict clauses
func ( OnConflict) ( *Clause) {
.Expression =
}
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |