Open
Description
Describe the bug
Consider this Jet statement:
postgres.SELECT(postgres.Bool(true).EQ(postgres.String("foo").IS_NOT_NULL()))
It compiles to
SELECT TRUE::boolean = 'foo'::text IS NOT NULL;
Which, when you run it in Postgres, results in this error:
[42883] ERROR: operator does not exist: boolean = text
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
Position: 22
We get the error because the =
operator has higher precedence than IS [NOT] NULL
, so the expression gets parsed like this:
SELECT (TRUE::boolean = 'foo'::text) IS NOT NULL;
Environment (please complete the following information):
- OS: macosx
- Database: postgres 14
- Database driver: pgx
- Jet version: 2.13.0
Expected behavior
Jet knew what we meant. The .EQ()
method was expecting a BoolExpression
and we gave it a BoolExpression
, so I would have expected the query compiler to put parens around that expression:
SELECT TRUE::boolean = ('foo'::text IS NOT NULL);