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

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
- [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] 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)
......
......@@ -20,47 +20,46 @@
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@private
*/
var removeColumn = function(tableName, attributeName, options) {
var self = this;
options = options || {};
const removeColumn = function(tableName, attributeName, options) {
options = Object.assign({ raw: true }, options || {});
var findConstraintSql = self.QueryGenerator.getDefaultConstraintQuery(tableName, attributeName);
return self.sequelize.query(findConstraintSql, { raw: true, logging: options.logging})
.spread(function(results) {
const findConstraintSql = this.QueryGenerator.getDefaultConstraintQuery(tableName, attributeName);
return this.sequelize.query(findConstraintSql, options)
.spread(results => {
if (!results.length) {
// No default constraint found -- we can cleanly remove the column
return;
}
var dropConstraintSql = self.QueryGenerator.dropConstraintQuery(tableName, results[0].name);
return self.sequelize.query(dropConstraintSql, { raw: true, logging: options.logging});
const dropConstraintSql = this.QueryGenerator.dropConstraintQuery(tableName, results[0].name);
return this.sequelize.query(dropConstraintSql, options);
})
.then(function() {
var findForeignKeySql = self.QueryGenerator.getForeignKeyQuery(tableName, attributeName);
return self.sequelize.query(findForeignKeySql, { raw: true, logging: options.logging});
.then(() => {
const findForeignKeySql = this.QueryGenerator.getForeignKeyQuery(tableName, attributeName);
return this.sequelize.query(findForeignKeySql, options);
})
.spread(function(results) {
.spread(results => {
if (!results.length) {
// No foreign key constraints found, so we can remove the column
return;
}
var dropForeignKeySql = self.QueryGenerator.dropForeignKeyQuery(tableName, results[0].constraint_name);
return self.sequelize.query(dropForeignKeySql, { raw: true, logging: options.logging});
const dropForeignKeySql = this.QueryGenerator.dropForeignKeyQuery(tableName, results[0].constraint_name);
return this.sequelize.query(dropForeignKeySql, options);
})
.then(() => {
//Check if the current column is a primaryKey
const primaryKeyConstraintSql = self.QueryGenerator.getPrimaryKeyConstraintQuery(tableName, attributeName);
return self.sequelize.query(primaryKeyConstraintSql, { raw: true, logging: options.logging });
const primaryKeyConstraintSql = this.QueryGenerator.getPrimaryKeyConstraintQuery(tableName, attributeName);
return this.sequelize.query(primaryKeyConstraintSql, options);
})
.spread(result => {
if (!result.length) {
return;
}
const dropConstraintSql = self.QueryGenerator.dropConstraintQuery(tableName, result[0].constraintName);
return self.sequelize.query(dropConstraintSql, { raw: true, logging: options.logging});
const dropConstraintSql = this.QueryGenerator.dropConstraintQuery(tableName, result[0].constraintName);
return this.sequelize.query(dropConstraintSql, options);
})
.then(function() {
var removeSql = self.QueryGenerator.removeColumnQuery(tableName, attributeName);
return self.sequelize.query(removeSql, { raw: true, logging: options.logging});
.then(() => {
const removeSql = this.QueryGenerator.removeColumnQuery(tableName, attributeName);
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!