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

T-SQL: Allow aliases with = #2727

Merged
merged 3 commits into from Feb 27, 2022
Merged

T-SQL: Allow aliases with = #2727

merged 3 commits into from Feb 27, 2022

Conversation

fdw
Copy link
Contributor

@fdw fdw commented Feb 27, 2022

Brief summary of the change made

Now supports T-SQL's alias syntax with =.

Fixed #2552

Are there any other side effects of this change that we should be aware of?

I think the alias should still be recognized correctly as such, but I'm not 100% sure.

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

@codecov
Copy link

codecov bot commented Feb 27, 2022

Codecov Report

Merging #2727 (67644ef) into main (cb90c89) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #2727   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          163       163           
  Lines        12046     12050    +4     
=========================================
+ Hits         12046     12050    +4     
Impacted Files Coverage Δ
src/sqlfluff/dialects/dialect_tsql.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb90c89...67644ef. Read the comment docs.

@tunetheweb
Copy link
Member

This will still flag for rule L012. But In guess we should just turn off that rule if using this style of SQL? However then no way of enforcing this style so someone could use mixed styles.

Ideally we'd update L012 to recognise this as an implicit alias but maybe that's beyond the scope of this PR? WDYT?

@fdw
Copy link
Contributor Author

fdw commented Feb 27, 2022

For this PR, I just wanted it to parse 😉 (That might also fix #2708.)

However, there's also #2487. As I've written there, I would like to offer a third option next to explicit and implicit just for T-SQL that forces everything to use =, which would also mean that the parser can distinguish between the three styles.
If you're alright with this, I'd suggest using this PR just for parsing and to continue the discussion about the rules in the issue 🙂

@tunetheweb
Copy link
Member

SGTM!

@tunetheweb tunetheweb merged commit 2070760 into sqlfluff:main Feb 27, 2022
@tunetheweb tunetheweb changed the title T-SQL: Allow aliases with = T-SQL: Allow aliases with = Mar 6, 2022
@fdw fdw deleted the 2552 branch April 23, 2022 15:40
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 this pull request may close these issues.

TSQL: Add support for column alias with equals (=) operator to rule L013
2 participants