不要怂,就是干,撸起袖子干!

Commit 70c359eb by Stefano Dalpiaz Committed by Sushant

Add quotes around column names for unique constraints in sqlite (fixes #4407) (#7224)

* Add quotes around column names for unique constraints in sqlite (fixes #4407)

* Changelog linked to issue
1 parent 6efc2ad2
......@@ -49,6 +49,7 @@
- [INTERNAL] Updated to `generic-pool@3.1.6` [#7109](https://github.com/sequelize/sequelize/issues/7109)
- [FIXED] findAll throws error if attributes option is formatted incorrectly [#7162](https://github.com/sequelize/sequelize/issues/7163)
- [FIXED] previous gave wrong value back [#7189](https://github.com/sequelize/sequelize/pull/7189)
- [FIXED] Add quotes around column names for unique constraints in sqlite [#4407](https://github.com/sequelize/sequelize/pull/4407)
- [FIXED] Connection error when fetching OIDs for unspported types in Postgres 8.2 or below [POSTGRES] [#5254](https://github.com/sequelize/sequelize/issues/5254)
## BC breaks:
......
......@@ -64,7 +64,7 @@ const QueryGenerator = {
if (!!options.uniqueKeys) {
Utils._.each(options.uniqueKeys, columns => {
if (!columns.singleField) { // If it's a single field its handled in column def, not as an index
attrStr += ', UNIQUE (' + columns.fields.join(', ') + ')';
attrStr += ', UNIQUE (' + columns.fields.map(field => this.quoteIdentifier(field)).join(', ') + ')';
}
});
}
......
......@@ -135,6 +135,10 @@ if (dialect === 'sqlite') {
{
arguments: ['myTable', {id: 'INTEGER PRIMARY KEY AUTOINCREMENT', name: 'VARCHAR(255)'}],
expectation: 'CREATE TABLE IF NOT EXISTS `myTable` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255));'
},
{
arguments: ['myTable', {id: 'INTEGER PRIMARY KEY AUTOINCREMENT', name: 'VARCHAR(255)', surname: 'VARCHAR(255)'}, {uniqueKeys: {uniqueConstraint: {fields: ['name', 'surname']}}}],
expectation: 'CREATE TABLE IF NOT EXISTS `myTable` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255), `surname` VARCHAR(255), UNIQUE (`name`, `surname`));'
}
],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!