MCPcopy
hub / github.com/ent/ent / ValueIsNotNull

Function ValueIsNotNull

dialect/sql/sqljson/sqljson.go:70–89  ·  view source on GitHub ↗

ValueIsNotNull return a predicate for checking that a JSON value (returned by the path) is not null literal (JSON "null"). sqljson.ValueIsNotNull("a", sqljson.Path("b"))

(column string, opts ...Option)

Source from the content-addressed store, hash-verified

68//
69// sqljson.ValueIsNotNull("a", sqljson.Path("b"))
70func ValueIsNotNull(column string, opts ...Option) *sql.Predicate {
71 return sql.P(func(b *sql.Builder) {
72 switch b.Dialect() {
73 case dialect.Postgres:
74 valuePath(b, column, append(opts, Cast("jsonb"))...)
75 b.WriteOp(sql.OpNEQ).WriteString("'null'::jsonb")
76 case dialect.SQLite:
77 path := identPath(column, opts...)
78 path.mysqlFunc("JSON_TYPE", b)
79 b.WriteOp(sql.OpNEQ).WriteString("'null'")
80 case dialect.MySQL:
81 path := identPath(column, opts...)
82 b.WriteString("NOT(JSON_CONTAINS").Wrap(func(b *sql.Builder) {
83 b.Ident(column).Comma()
84 b.WriteString("'null'").Comma()
85 path.mysqlPath(b)
86 }).WriteString(")")
87 }
88 })
89}
90
91// ValueEQ return a predicate for checking that a JSON value
92// (returned by the path) is equal to the given argument.

Callers 2

PredicatesFunction · 0.92
TestWritePathFunction · 0.92

Calls 12

PStruct · 0.92
valuePathFunction · 0.85
CastFunction · 0.85
identPathFunction · 0.85
WriteStringMethod · 0.80
WriteOpMethod · 0.80
mysqlFuncMethod · 0.80
WrapMethod · 0.80
CommaMethod · 0.80
IdentMethod · 0.80
mysqlPathMethod · 0.80
DialectMethod · 0.65

Tested by 2

PredicatesFunction · 0.74
TestWritePathFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…