Repository navigation
Add quotes around column names for unique constraints in sqlite (fixes #4407) - #7224
Conversation
ffb1fd7 to
6749e40
Compare
Codecov Report
Continue to review full report at Codecov.
|
|
Rather than integration test, we should add unit test for this change, because we just want to verify correct statement was generated |
6749e40 to
3af4cfe
Compare
|
As requested, I have removed the new integration tests and added a unit test. Also, is there any chance that this can be backported into v3? I can open another PR for that if needed. |
3af4cfe to
85affb9
Compare
Please go ahead and open a PR targeting v3, we will release new version for you :) |
Thanks, I just opened #7270 for this purpose. |
…sequelize#4407) (sequelize#7224) * Add quotes around column names for unique constraints in sqlite (fixes sequelize#4407) * Changelog linked to issue
This PR fixes a bug in the query generator for Sqlite, in which the definition of a composite unique constraint would not properly wrap in quotes the column names. This causes the statement to fail whenever a column name is the same as a reserved keyword (like
order,group,index, ...), or when it contains certain non alpha-numerical characters (like a space).For example the following declaration:
would generate the following statement (new lines added for readability):
The above statement contains a syntax error, as the name
column with spaceinside theUNIQUEconstraint must be wrapped in quotes.This PR modifies the logic that builds that statement to ensure that those names are properly wrapped.
I have also provided a couple of tests to prevent regression.