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

sqlfmt adds an extra space to PostgreSQL double tilda operators (LIKE alias) #576

Closed
tuckerrc opened this issue Apr 24, 2024 · 3 comments · Fixed by #577
Closed

sqlfmt adds an extra space to PostgreSQL double tilda operators (LIKE alias) #576

tuckerrc opened this issue Apr 24, 2024 · 3 comments · Fixed by #577

Comments

@tuckerrc
Copy link

Describe the bug

PostgreSQL has a few aliases for the LIKE keyword (9.7.1. LIKE). sqlfmt adds a space between the ~~ operator, breaking the query.

Other operators specific to PostgreSQL (from the docs)

The operator ~~ is equivalent to LIKE, and ~~* corresponds to ILIKE. There are also !~~ and !~~* operators that represent NOT LIKE and NOT ILIKE, respectively. All of these operators are PostgreSQL-specific.

To Reproduce
Steps to reproduce the behavior. If this is a formatting issue, include the input code here.

Input

with test as (select 'test' as test) select * from test where test ~~ 'test'

sqlfmt output

with test as (select 'test' as test) select * from test where test ~ ~ 'test'

Expected behavior

No spaces are added to the ~~ operator

Additional context
What is the output of sqlfmt --version?

$ sqlfmt --version
sqlfmt, version 0.21.2
@tconbeer
Copy link
Owner

Had no idea that was a thing. Thanks for the report!

@tconbeer
Copy link
Owner

@tuckerrc this has been patched in v0.21.3

@tuckerrc
Copy link
Author

Thank you for the quick turnaround! I discovered it yesterday when sqlfmt broke a query in a large project. Now I don't need to change that query!

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

Successfully merging a pull request may close this issue.

2 participants