gorm/clause/returning.go

35 lines
681 B
Go
Raw Permalink Normal View History

2020-02-07 18:45:35 +03:00
package clause
type Returning struct {
Columns []Column
}
// Name where clause name
func (returning Returning) Name() string {
return "RETURNING"
}
// Build build where clause
func (returning Returning) Build(builder Builder) {
2021-10-28 02:24:38 +03:00
if len(returning.Columns) > 0 {
for idx, column := range returning.Columns {
if idx > 0 {
builder.WriteByte(',')
}
2020-02-07 18:45:35 +03:00
2021-10-28 02:24:38 +03:00
builder.WriteQuoted(column)
}
} else {
builder.WriteByte('*')
2020-02-07 18:45:35 +03:00
}
}
// MergeClause merge order by clauses
func (returning Returning) MergeClause(clause *Clause) {
if v, ok := clause.Expression.(Returning); ok {
returning.Columns = append(v.Columns, returning.Columns...)
}
clause.Expression = returning
}