Skip to content

Incorrect parsing of Postgres GiST operator @> adds unexpected whitespace #17

Description

@ibarchenkov

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 "@>" do
    assert "where id @> transaction_timestamp()" == to_string(~SQL[where id @> transaction_timestamp()])
  end
end

Which fails with:

  1) test operators @> (SQL.Adapters.PostgresTest)
     test/adapters/postgres_test.exs:267
     Assertion with == failed
     code:  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?

Thanks!

Activity

  1. Schultzer commented on Jun 22, 2025

    @Schultzer
    Member

    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.

  2. added
    bug
    on Jun 23, 2025
  3. added a commit that references this issue on Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions