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
Prevent exceptions when running fix
on dialect fixtures
#2818
Changes from all commits
9b04538
1e9a638
7b7c94b
f754e88
6bad08a
5fc5e05
8cae273
674d7fc
d5ee8fb
7777352
b35a846
e0ced71
0187671
e822b79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,8 +128,7 @@ def _generate_fixes( | |
) -> Optional[List[LintResult]]: | ||
"""Iterate through references and check consistency.""" | ||
# How many aliases are there? If more than one then abort. | ||
assert len(table_aliases) > 0, "Only Selects with tables should be checked" | ||
if len(table_aliases) > 1: | ||
if len(table_aliases) != 1: | ||
return None | ||
Comment on lines
-131
to
132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't see why we abort on more than one, but not on 0? Same thing IMHO and this fixes one of the issues raised. |
||
|
||
# A buffer to keep any violations. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
echo "This script will run 'sqlfluff fix -f' on all our dialect fixtures" | ||
echo "to look for critical errors." | ||
echo "WARNING this will change the fixtures so do not commit these changes!" | ||
|
||
DIALECTS=($( ls -d test/fixtures/dialects/*/ )) | ||
for DIALECT in "${DIALECTS[@]}" | ||
do | ||
echo "Testing $DIALECT SQL files fix without critical errors..." | ||
OUTPUT=$(sqlfluff fix -f ${DIALECT}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interested in adding other There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already the longest running job so would suggest a separate, parallel, job if we do that. However I did test it with Are you still getting the errors if you do it on this branch? Cause if not, then no need to add. The default config identified the issues and they were fixed. |
||
echo "${OUTPUT}" | grep -i -q critical | ||
# exit error, if match | ||
if [ $? -eq 0 ]; then | ||
echo "Critical errors found:" | ||
echo "${OUTPUT}" | grep -i "critical\|test/fixtures" | grep -i critical -A 1 | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "WARNING If running locally you should revert the changes." |
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.
Review this bit hiding whitespace: