dialect/sql/sqljson: inline boolean values (#3570)

Some drivers like mysql encodes them as 0/1
This commit is contained in:
Ariel Mashraki
2023-05-29 17:15:32 +03:00
committed by GitHub
parent 633d021f48
commit a8851db571
3 changed files with 31 additions and 1 deletions

View File

@@ -36,6 +36,13 @@ func TestWritePath(t *testing.T) {
wantQuery: "SELECT * FROM `users` WHERE JSON_EXTRACT(`a`, '$.b.c[1].d') = ?",
wantArgs: []any{"a"},
},
{
input: sql.Dialect(dialect.MySQL).
Select("*").
From(sql.Table("users")).
Where(sqljson.ValueEQ("a", true, sqljson.DotPath("b.c[1].d"))),
wantQuery: "SELECT * FROM `users` WHERE JSON_EXTRACT(`a`, '$.b.c[1].d') = true",
},
{
input: sql.Dialect(dialect.MySQL).
Select("*").