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

integer division // operator reformatted as comment #548

Open
manlon opened this issue Jan 13, 2024 · 2 comments
Open

integer division // operator reformatted as comment #548

manlon opened this issue Jan 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@manlon
Copy link

manlon commented Jan 13, 2024

// is an integer division operator in duckdb sql https://duckdb.org/docs/sql/functions/numeric.html
sqlfmt interprets this as the start of a comment and reformats it to -- with invalid results.

$ echo 'select 5 // 2;' | sqlfmt  -
select 5  -- 2;

1 file formatted.
0 files left unchanged.
- formatted.

Expected behavior
valid // operation passes through unchanged

Actual behavior
// is changed to -- as above

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

sqlfmt, version 0.21.1
@manlon
Copy link
Author

manlon commented Jan 13, 2024

I found the reason for this here #468 , but it's totally catastrophic when formatting duckdb queries with this op unfortunately

@tconbeer
Copy link
Owner

tconbeer commented Jan 13, 2024

Yeah, this is unfortunate. I checked as many dialects as I could and thought we were in the clear with //

Will have to be fixed with either a snowflake specific or duckdb specific dialect.

Workaround would be a --fmt: off comment on a PRECEDING line (same line won't work unfortunately)

@tconbeer tconbeer added the bug Something isn't working label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants