-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
QUAL: Add sqlfluff (SQL code and style check) #29097
Conversation
c454a40
to
afd728d
Compare
adding primary key on multiple columns:sqlfluff does not accept (parse) a line like this: ALTER TABLE example ADD PRIMARY KEY pk_example (fk_table1, fk_table2); but it accepts ALTER TABLE table0 ADD CONSTRAINT pk_example PRIMARY KEY (fk_table1, fk_table2); Which matches an example in: Such a case can be found in htdocs/install/mysql/migration/3.1.0-3.2.0.sql on line 160:
I did not examine mysql's documentation on this. Something that I should try to get parsed by sqlfluff or something that should be updated in dolibarr ? Use of rowidrowid is considered a keyword and it is also colored in my editor: A solution is to quote the field Ignore the sqlfluf notice or update the sql files to quote the rowid field name. EDIT: |
May be we can exclude files into dev/initdemo/ to avoid errors We don't mind scanning such files mysqldump as they are no code written by user but generated by mysql dump. |
Yes, the SQL has a wrong syntax. Howerver, it works correctly. As such sql files were provided on old version (and were working correctly), it is not a good idea to modify files tagged on old past version. |
They are still executed on more recent versions of mysql in theory they should be updated - I think that the syntax is also wrong for the old sql versions. However to avoid the work of modifying them, they can be excluded. |
2f1b16b
to
a086856
Compare
@eldy I propose to:
|
65e289c
to
cdc3beb
Compare
# QUAL: Add sqlfluff (SQL code and style check) This adds a validity and style check on the .sql files. The same tool can be used to fix style (which can be set up as a pre-commit hook).
The CI will run sqlfluff on all enabled files in the main branches, only on changed files in pull requets. |
QUAL: Add sqlfluff (SQL code and style check)
This adds a validity and style check on the .sql files. The same tool can be used to fix style (which can be set up as a pre-commit hook).
Curerntly there is an issue in sqlfluff as it does not accept empty "--" comments.
It also notifies that 'rowid' is a keyword. It may be a biter overzealous there. The message can be avoided by quoting the rowid field in backticks ("
rowid
").