ValueEQ return a predicate for checking that a JSON value (returned by the path) is equal to the given argument. sqljson.ValueEQ("a", 1, sqljson.Path("b"))
(column string, arg any, opts ...Option)
| 93 | // |
| 94 | // sqljson.ValueEQ("a", 1, sqljson.Path("b")) |
| 95 | func ValueEQ(column string, arg any, opts ...Option) *sql.Predicate { |
| 96 | return sql.P(func(b *sql.Builder) { |
| 97 | opts = normalizePG(b, arg, opts) |
| 98 | valuePath(b, column, opts...) |
| 99 | b.WriteOp(sql.OpEQ) |
| 100 | // Inline boolean values, as some drivers (e.g., MySQL) encode them as 0/1. |
| 101 | if v, ok := arg.(bool); ok { |
| 102 | b.WriteString(strconv.FormatBool(v)) |
| 103 | } else { |
| 104 | b.Arg(arg) |
| 105 | } |
| 106 | }) |
| 107 | } |
| 108 | |
| 109 | // ValueNEQ return a predicate for checking that a JSON value |
| 110 | // (returned by the path) is not equal to the given argument. |
searching dependent graphs…