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

L014 triggered by leading underscore #3780

Closed
2 of 3 tasks
j-svensmark opened this issue Aug 25, 2022 · 3 comments · Fixed by #3841
Closed
2 of 3 tasks

L014 triggered by leading underscore #3780

j-svensmark opened this issue Aug 25, 2022 · 3 comments · Fixed by #3841
Labels
bug Something isn't working

Comments

@j-svensmark
Copy link
Contributor

Search before asking

  • I searched the issues and found no similar issues.

What Happened

When parsing a file with sqlfluff, I unexpectedly got a Unquoted identifiers must be consistently capitalised. error from L014. Here is an MWE

select
    _a,
    b
from foo

Expected Behaviour

I expect running sqlfluff on the above code sample shouldn't produce any error.

Observed Behaviour

When running sqlfluff lint --dialect bigquery MWE.sql I get an error from L014

== [......................../MWE.sql] FAIL
L:   3 | P:   5 | L014 | Unquoted identifiers must be consistently capitalised.
L:   4 | P:   6 | L014 | Unquoted identifiers must be consistently capitalised.
All Finished 📜 🎉!

How to reproduce

See above

Dialect

I tested with bigquery, oracle and tsql, and the issue occurred in all of them. I assume it applies to all dialects.

Version

Running in a conda env on M1 Macbook with

sqlfluff, version 1.3.0
python                    3.9.7                h88f2d9e_1

Configuration

No custom config used.

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

@j-svensmark j-svensmark added the bug Something isn't working label Aug 25, 2022
@j-svensmark
Copy link
Contributor Author

j-svensmark commented Aug 25, 2022

I suspect the logic here might be the triggering cause of this issue

if segment.raw[0] != segment.raw[0].upper():

Is it implicitly assumed that the first character is a capitalizable letter?

@alanmcruickshank
Copy link
Member

Yep - 100% right on why this is happening. I think this should be a fairly easy fix to find the first character where casing matters and infer from that one 👍 . @j-svensmark - would you be up for submitting a PR for this?

@j-svensmark
Copy link
Contributor Author

Sure, please see the PR linked above.
Btw, in case anyone needs a workaround for this, explicitly setting the capitalization policy in the .sqlfluff config silences this linting error

[sqlfluff:rules:L014]
extended_capitalisation_policy = lower

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

Successfully merging a pull request may close this issue.

2 participants