-
-
Notifications
You must be signed in to change notification settings - Fork 729
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
Add config CLI argument to lint, fix, and parse #1986
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1986 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 148 148
Lines 10292 10305 +13
=========================================
+ Hits 10292 10305 +13
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but how do we know that the extra config is being used? Tests don't seem to check that.
Also test/fixtures/cli/extra_config_tsql.sql is empty which looks a little odd.
Maybe we could fix both concerns by adding some T-SQL specific SQL that fails in ANSI to check the dialect has indeed been changed as per the extra config?
@tunetheweb weird that's exactly what the test was! Not sure how it didn't commit that sql but will add it back in now 😄 |
@tunetheweb I've re-added that missing unit test back in 👍 |
Brief summary of the change made
Fixes #1244.
This PR adds a command line argument
--config
to the CLIlint
,fix
, andparse
commands.The user can specify an additional config file such that the override logic is (later files override earlier ones):
default_config.cfg
(package default)<user_appdir_configs>
<user_homedir_configs>
<user_homedir_configs>
<configs_between_cwd_and_sql_path>
<extra_config_file>
(this PR)This behaviour was voted on in the Slack channel: https://sqlfluff.slack.com/archives/C01GPHR8J0G/p1637859667129900
If no config files are included in the default config search paths then this argument can be used to specify a single off-path config file which will also be useful for several applications.
(Will investigate in a future PR adding
--ignore-local-config
option to allow only--config
to be considered)N.B. This PR focuses on the CLI, I will make a subsequent PR to flow the changes through to the Simple API as well.
Are there any other side effects of this change that we should be aware of?
No
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 intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withpython test/generate_parse_fixture_yml.py
or by runningtox
locally).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.