Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several PostgreSQL operators are incorrectly split in two #52

Open
Diggsey opened this issue Sep 10, 2024 · 1 comment
Open

Several PostgreSQL operators are incorrectly split in two #52

Diggsey opened this issue Sep 10, 2024 · 1 comment

Comments

@Diggsey
Copy link

Diggsey commented Sep 10, 2024

Some examples I've encountered:

Before After
<-> < ->
<=> <= >
&& & &
@> @ >

There are probably many more. I think the formatter should avoid splitting adjacent symbols like this entirely.

@pnezis
Copy link

pnezis commented Oct 10, 2024

Some other examples that are wrongly split:

SELECT
  left <@ right,
  left << right,
  left >> right,
  left &< right,
  left &> right,
  left -|- right,
  @@ left,
  @-@ left,
  left <-> right,
  left <<| right,
  left |>> right,
  left &<| right,
  left |>& right,
  left <^ right,
  left >^ right,
  ?- left,
  left ?-| right,
  left ?|| right,
  left ~= right

Notice that this is only a tiny subset of postgres supported operators. You can get the full list by running

select * from pg_operator;

Additionally you are allowed to create your own operator through CREATE OPERATOR. The allowed operator characters are + - * / < > = ~ ! @ # % ^ & | ?`.

I agree with @Diggsey that the tokenizer should avoid splitting sequences of the above symbols in order to be safe. Currently it breaks queries using such operators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants