gorm/clause/insert.go

35 lines
645 B
Go
Raw Normal View History

2020-02-03 05:40:03 +03:00
package clause
type Insert struct {
Table Table
Priority string
}
// Name insert clause name
func (insert Insert) Name() string {
return "INSERT"
}
// Build build insert clause
func (insert Insert) Build(builder Builder) {
if insert.Priority != "" {
builder.Write(insert.Priority)
builder.WriteByte(' ')
}
builder.Write("INTO ")
builder.WriteQuoted(insert.Table)
}
// MergeExpression merge insert clauses
func (insert Insert) MergeExpression(expr Expression) {
if v, ok := expr.(Insert); ok {
if insert.Priority == "" {
insert.Priority = v.Priority
}
if insert.Table.Table == "" {
insert.Table = v.Table
}
}
}