This commit is contained in:
2024-05-09 16:59:25 +08:00
parent 65b9f3795d
commit 90f807defc
12 changed files with 1283 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package clauses
import (
"gorm.io/gorm/clause"
)
type WhenNotMatched struct {
clause.Values
Where clause.Where
}
func (w WhenNotMatched) Name() string {
return "WHEN NOT MATCHED"
}
func (w WhenNotMatched) Build(builder clause.Builder) {
if len(w.Columns) > 0 {
if len(w.Values.Values) != 1 {
panic("cannot insert more than one rows due to Oracle SQL language restriction")
}
builder.WriteString(" THEN")
builder.WriteString(" INSERT ")
w.Build(builder)
if len(w.Where.Exprs) > 0 {
builder.WriteString(w.Where.Name())
builder.WriteByte(' ')
w.Where.Build(builder)
}
}
}