You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library is very promising — thanks for releasing it!
While testing against Postgres, I noticed a possible issue with how some GiST operators are parsed or rendered.
To reproduce, add the following test to test/adapters/postgres_test.exs:
describe"operators"do...test"@>"doassert"where id @> transaction_timestamp()"==to_string(~SQL[where id @> transaction_timestamp()])endend
Which fails with:
1)testoperators@>(SQL.Adapters.PostgresTest)test/adapters/postgres_test.exs:267Assertionwith==failedcode: assert"where id @> transaction_timestamp()"==to_string(~SQL[where id @> transaction_timestamp()])left: "where id @> transaction_timestamp()"right: "where id @ > transaction_timestamp ()"stacktrace:
test/adapters/postgres_test.exs:268: (test)
As shown, to_string/1 inserts an unexpected space between @ and > and between the function name and its parentheses. This breaks the intended SQL syntax.
I'm not sure of the exact root cause, but would appreciate if someone familiar with the parser could take a look.
Would it also be possible to support all of PostgreSQL's built-in GiST operators?
You would properly have to add code other places as well, I’m currently working on a bigger refactoring of the generator. But that is still gonna take some time.
Activity
Schultzer commentedon Jun 22, 2025
You are correct, Gist operators are currently not handled by the lexer if you’re down for it you can push a PR and add it here: https://github.com/elixir-dbvisor/sql/blob/main/lib/mix/tasks/sql.gen.parser.ex#L425
You would properly have to add code other places as well, I’m currently working on a bigger refactoring of the generator. But that is still gonna take some time.
Add Postgres GiST operators elixir-dbvisor#17
Add Postgres GiST operators #17 (#18)