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

Commit 6bfb337c by Harshith Kashyap Committed by Sushant

Pass options object to MSSQL removeColumn queries (#7193)

* Pass options to MSSQL removeColumn queries

* [ci skip] Added changelog entry

* Review fixes - Use Object.assign instead of lodash assign

* Update changelog description
1 parent 118b4e9d
# Future # Future
- [FIXED] Properly pass options to `sequelize.query` in `removeColumn` [MSSQL] [#7193](https://github.com/sequelize/sequelize/pull/7193)
- [FIXED] Updating `VIRTUAL` field throw `ER_EMPTY_QUERY` [#6356](https://github.com/sequelize/sequelize/issues/6356) - [FIXED] Updating `VIRTUAL` field throw `ER_EMPTY_QUERY` [#6356](https://github.com/sequelize/sequelize/issues/6356)
- [FIXED] Fix `Instance.decrement` precision problems [#7112](https://github.com/sequelize/sequelize/pull/7112) - [FIXED] Fix `Instance.decrement` precision problems [#7112](https://github.com/sequelize/sequelize/pull/7112)
- [FIXED] MSSQL tedious debug regression fix when dialectOptions are not passed [#7130](https://github.com/sequelize/sequelize/pull/7130) - [FIXED] MSSQL tedious debug regression fix when dialectOptions are not passed [#7130](https://github.com/sequelize/sequelize/pull/7130)
......
...@@ -20,47 +20,46 @@ ...@@ -20,47 +20,46 @@
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries @param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@private @private
*/ */
var removeColumn = function(tableName, attributeName, options) { const removeColumn = function(tableName, attributeName, options) {
var self = this; options = Object.assign({ raw: true }, options || {});
options = options || {};
var findConstraintSql = self.QueryGenerator.getDefaultConstraintQuery(tableName, attributeName); const findConstraintSql = this.QueryGenerator.getDefaultConstraintQuery(tableName, attributeName);
return self.sequelize.query(findConstraintSql, { raw: true, logging: options.logging}) return this.sequelize.query(findConstraintSql, options)
.spread(function(results) { .spread(results => {
if (!results.length) { if (!results.length) {
// No default constraint found -- we can cleanly remove the column // No default constraint found -- we can cleanly remove the column
return; return;
} }
var dropConstraintSql = self.QueryGenerator.dropConstraintQuery(tableName, results[0].name); const dropConstraintSql = this.QueryGenerator.dropConstraintQuery(tableName, results[0].name);
return self.sequelize.query(dropConstraintSql, { raw: true, logging: options.logging}); return this.sequelize.query(dropConstraintSql, options);
}) })
.then(function() { .then(() => {
var findForeignKeySql = self.QueryGenerator.getForeignKeyQuery(tableName, attributeName); const findForeignKeySql = this.QueryGenerator.getForeignKeyQuery(tableName, attributeName);
return self.sequelize.query(findForeignKeySql, { raw: true, logging: options.logging}); return this.sequelize.query(findForeignKeySql, options);
}) })
.spread(function(results) { .spread(results => {
if (!results.length) { if (!results.length) {
// No foreign key constraints found, so we can remove the column // No foreign key constraints found, so we can remove the column
return; return;
} }
var dropForeignKeySql = self.QueryGenerator.dropForeignKeyQuery(tableName, results[0].constraint_name); const dropForeignKeySql = this.QueryGenerator.dropForeignKeyQuery(tableName, results[0].constraint_name);
return self.sequelize.query(dropForeignKeySql, { raw: true, logging: options.logging}); return this.sequelize.query(dropForeignKeySql, options);
}) })
.then(() => { .then(() => {
//Check if the current column is a primaryKey //Check if the current column is a primaryKey
const primaryKeyConstraintSql = self.QueryGenerator.getPrimaryKeyConstraintQuery(tableName, attributeName); const primaryKeyConstraintSql = this.QueryGenerator.getPrimaryKeyConstraintQuery(tableName, attributeName);
return self.sequelize.query(primaryKeyConstraintSql, { raw: true, logging: options.logging }); return this.sequelize.query(primaryKeyConstraintSql, options);
}) })
.spread(result => { .spread(result => {
if (!result.length) { if (!result.length) {
return; return;
} }
const dropConstraintSql = self.QueryGenerator.dropConstraintQuery(tableName, result[0].constraintName); const dropConstraintSql = this.QueryGenerator.dropConstraintQuery(tableName, result[0].constraintName);
return self.sequelize.query(dropConstraintSql, { raw: true, logging: options.logging}); return this.sequelize.query(dropConstraintSql, options);
}) })
.then(function() { .then(() => {
var removeSql = self.QueryGenerator.removeColumnQuery(tableName, attributeName); const removeSql = this.QueryGenerator.removeColumnQuery(tableName, attributeName);
return self.sequelize.query(removeSql, { raw: true, logging: options.logging}); return this.sequelize.query(removeSql, options);
}); });
}; };
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!