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
Allow optional keywords in create table
unique constraints
#2077
Allow optional keywords in create table
unique constraints
#2077
Conversation
create table
constraintscreate table
unique constraints
@kayman-mk I'm conscious that this PR is impacting the same area of the code as #2076 that we've just merged in. Can you update your fork and deal with any potential merge conflicts before I review? |
@jpy-git Branch updated. No conflicts found. |
Codecov Report
@@ Coverage Diff @@
## main #2077 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 148 148
Lines 10599 10603 +4
=========================================
+ Hits 10599 10603 +4
Continue to review full report at Codecov.
|
So I can see this implementation in the mysql docs: https://dev.mysql.com/doc/refman/8.0/en/create-table.html#:~:text=%5BCONSTRAINT%20%5Bsymbol%5D%5D%20UNIQUE%20%5BINDEX%20%7C%20KEY%5D However reading the postgres docs the syntax for unique constraints seems to be different?: https://www.postgresql.org/docs/14/sql-createtable.html |
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.
@kayman-mk can you move this logic to mysql specific please?
@kayman-mk great work, thanks for adding this! 🥇 For some reason I don't have the usual option to update the branch for the latest changes in main 🤷 Could you just pull in the latest changes from main and then we can get this merged in? Thanks 😄 |
When people open a PR there’s a tick box to allow maintainers to alter the branch. Most people leave it ticked to allow small changes and updates to be applied. |
@tunetheweb ah makes sense thanks! 😄 |
Brief summary of the change made
Allows optional keywords and index name in
unique
constraints ofcreate table
.key
andindex
keywords are optionalAt least MySql and PostgreSql are using this syntax. I didn't found anything in SQL-99 but the implementation was already present in
dialect_mysql.py
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.