-
Notifications
You must be signed in to change notification settings - Fork 19
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
unexpected layout.spacing
rule application on grant
statements
#924
Comments
Strange, I can't reproduce that behavior in the playground. |
PS C:\Users\gvozdvmozgu\Projects\sqruff> cat .\.sqlfluff
[.sqruff]
dialect = postgres
PS C:\Users\gvozdvmozgu\Projects\sqruff> cat .\pg.sql
grant some_role to a_user;
PS C:\Users\gvozdvmozgu\Projects\sqruff> cargo r --quiet -- lint .\pg.sql
The linter processed 1 file(s).
All Finished 📜 🎉
PS C:\Users\gvozdvmozgu\Projects\sqruff> |
My apologies - I didn't test the case where it's the only line in the file, in which case the bug doesn't occur. I'm trying to figure out what triggers it in my actual script, I'll reply with what I find shortly. |
then most likely the error is due to incorrect parsing of the SQL file |
Okay, so it seems that grant some_role to a_user with admin true;
grant some_role to a_user; gets reformatted to grant some_role to a_user with admin true ;
grant some_role to a_user ; meaning that adding |
The part "with admin" breaks the parser. file:
- statement:
- access_statement:
- keyword: grant
- whitespace: ' '
- object_reference:
- naked_identifier: some_role
- whitespace: ' '
- keyword: to
- whitespace: ' '
- role_reference:
- naked_identifier: a_user
- whitespace: ' '
- file:
- word: with
- whitespace: ' '
- word: admin
- whitespace: ' '
- word: 'true'
- semicolon: ;
- newline: |2+
- word: grant
- whitespace: ' '
- word: some_role
- whitespace: ' '
- word: to
- whitespace: ' '
- word: a_user
- semicolon: ;
- end_of_file: '' |
I wouldn't necessarily classify this as a bug, but it seems unexpected to me that the following line of SQL:
grant some_role to a_user;
triggers the
layout.spacing
rule, causingsqruff
to reformat to:Is this behavior desired/expected? For reference, I'm running
sqruff
v0.20.2, and my.sqruff
file is justThe text was updated successfully, but these errors were encountered: