MCPcopy
hub / github.com/ent/ent / setCase

Function setCase

dialect/sql/sqljson/dialect.go:203–214  ·  view source on GitHub ↗

setCase sets the column value using the "CASE WHEN" statement. The x defines the condition/predicate, t is the true (if) case, and 'f' defines the false (else).

(u *sql.UpdateBuilder, column string, w when)

Source from the content-addressed store, hash-verified

201// The x defines the condition/predicate, t is the true (if) case,
202// and 'f' defines the false (else).
203func setCase(u *sql.UpdateBuilder, column string, w when) {
204 u.Set(column, sql.ExprFunc(func(b *sql.Builder) {
205 b.WriteString("CASE WHEN ").Wrap(func(b *sql.Builder) {
206 w.Cond(b)
207 })
208 b.WriteString(" THEN ")
209 w.Then(b)
210 b.WriteString(" ELSE ")
211 w.Else(b)
212 b.WriteString(" END")
213 }))
214}
215
216func isPrimitive(v any) bool {
217 switch reflect.TypeOf(v).Kind() {

Callers 3

AppendMethod · 0.85
AppendMethod · 0.85
AppendMethod · 0.85

Calls 4

ExprFuncFunction · 0.92
WrapMethod · 0.80
WriteStringMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…