mirror of
https://github.com/ent/ent.git
synced 2026-04-28 13:40:56 +03:00
dialect/sql/sqljson: add {neq,gt,gte} to predicates (#756)
This commit is contained in:
@@ -92,6 +92,20 @@ func TestWritePath(t *testing.T) {
|
||||
wantQuery: `SELECT * FROM "users" WHERE CAST("a"->'b'->'c'->1->'d' AS int) = $1`,
|
||||
wantArgs: []interface{}{1},
|
||||
},
|
||||
{
|
||||
input: sql.Dialect(dialect.Postgres).
|
||||
Select("*").
|
||||
From(sql.Table("users")).
|
||||
Where(
|
||||
sql.Or(
|
||||
sqljson.ValueNEQ("a", 1, sqljson.Path("b")),
|
||||
sqljson.ValueGT("a", 1, sqljson.Path("c")),
|
||||
sqljson.ValueGTE("a", 1, sqljson.Path("d")),
|
||||
),
|
||||
),
|
||||
wantQuery: `SELECT * FROM "users" WHERE "a"->'b' <> $1 OR "a"->'c' > $2 OR "a"->'d' >= $3`,
|
||||
wantArgs: []interface{}{1, 1, 1},
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user