mirror of
https://github.com/ent/ent.git
synced 2026-04-28 13:40:56 +03:00
entc/integration/json: add tests for null literals
This commit is contained in:
committed by
Ariel Mashraki
parent
0c5398a11d
commit
3ba2b4e173
@@ -202,26 +202,12 @@ func TestWritePath(t *testing.T) {
|
||||
Where(sqljson.ValueIsNull("c", sqljson.Path("a"))),
|
||||
wantQuery: `SELECT * FROM "users" WHERE ("c"->'a')::jsonb = 'null'::jsonb`,
|
||||
},
|
||||
{
|
||||
input: sql.Dialect(dialect.Postgres).
|
||||
Select("*").
|
||||
From(sql.Table("users")).
|
||||
Where(sqljson.ValueNotNull("c", sqljson.Path("a"))),
|
||||
wantQuery: `SELECT * FROM "users" WHERE ("c"->'a')::jsonb <> 'null'::jsonb`,
|
||||
},
|
||||
{
|
||||
input: sql.Dialect(dialect.MySQL).
|
||||
Select("*").
|
||||
From(sql.Table("users")).
|
||||
Where(sqljson.ValueIsNull("c", sqljson.Path("a"))),
|
||||
wantQuery: "SELECT * FROM `users` WHERE JSON_EXTRACT(`c`, \"$.a\") = CAST('null' AS JSON)",
|
||||
},
|
||||
{
|
||||
input: sql.Dialect(dialect.MySQL).
|
||||
Select("*").
|
||||
From(sql.Table("users")).
|
||||
Where(sqljson.ValueNotNull("c", sqljson.Path("a"))),
|
||||
wantQuery: "SELECT * FROM `users` WHERE JSON_EXTRACT(`c`, \"$.a\") <> CAST('null' AS JSON)",
|
||||
wantQuery: "SELECT * FROM `users` WHERE JSON_CONTAINS(`c`, 'null', \"$.a\")",
|
||||
},
|
||||
{
|
||||
input: sql.Dialect(dialect.SQLite).
|
||||
@@ -230,13 +216,6 @@ func TestWritePath(t *testing.T) {
|
||||
Where(sqljson.ValueIsNull("c", sqljson.Path("a"))),
|
||||
wantQuery: "SELECT * FROM `users` WHERE JSON_TYPE(`c`, \"$.a\") = 'null'",
|
||||
},
|
||||
{
|
||||
input: sql.Dialect(dialect.SQLite).
|
||||
Select("*").
|
||||
From(sql.Table("users")).
|
||||
Where(sqljson.ValueNotNull("c", sqljson.Path("a"))),
|
||||
wantQuery: "SELECT * FROM `users` WHERE JSON_TYPE(`c`, \"$.a\") <> 'null'",
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user