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

Commit 2a7c7c73 by Ruben Bridgewater

Insert missing options / logging passed through to .query

1 parent a9158201
......@@ -50,7 +50,7 @@ module.exports = (function() {
var showSchemasSql = self.QueryGenerator.showSchemasQuery();
return this.sequelize.query(showSchemasSql, options).then(function(schemaNames) {
return this.sequelize.query(showSchemasSql, undefined, options).then(function(schemaNames) {
return Utils._.flatten(
Utils._.map(schemaNames, function(value) {
return (!!value.schema_name ? value.schema_name : value);
......@@ -150,8 +150,7 @@ module.exports = (function() {
else if (!!vals[idx - 1]) {
options.after = vals[idx - 1];
}
promises.push(self.sequelize.query(self.QueryGenerator.pgEnumAdd(getTableName, keys[i], value, options)));
promises.push(self.sequelize.query(self.QueryGenerator.pgEnumAdd(getTableName, keys[i], value, options), undefined, options));
}
});
enumIdx++;
......@@ -245,13 +244,13 @@ module.exports = (function() {
var skip = options.skip || [];
return self.showAllTables().then(function(tableNames) {
if (self.sequelize.options.dialect === 'sqlite') {
return self.sequelize.query('PRAGMA foreign_keys;').then(function(result) {
return self.sequelize.query('PRAGMA foreign_keys;', undefined, options).then(function(result) {
var foreignKeysAreEnabled = result.foreign_keys === 1;
if (foreignKeysAreEnabled) {
return self.sequelize.query('PRAGMA foreign_keys = OFF').then(function() {
return self.sequelize.query('PRAGMA foreign_keys = OFF', undefined, options).then(function() {
return dropAllTables(tableNames).then(function() {
return self.sequelize.query('PRAGMA foreign_keys = ON');
return self.sequelize.query('PRAGMA foreign_keys = ON', undefined, options);
});
});
} else {
......@@ -270,7 +269,7 @@ module.exports = (function() {
foreignKeys[normalizedTableName].forEach(function(foreignKey) {
var sql = self.QueryGenerator.dropForeignKeyQuery(tableName, foreignKey);
promises.push(self.sequelize.query(sql));
promises.push(self.sequelize.query(sql, undefined, options));
});
});
......@@ -325,19 +324,19 @@ module.exports = (function() {
if (typeof options === 'string') {
schema = options;
} else if (typeof options === 'object') {
} else if (typeof options === 'object' && options !== null) {
schema = options.schema || null;
schemaDelimiter = options.schemaDelimiter || null;
}
if (typeof tableName === 'object') {
if (typeof tableName === 'object' && tableName !== null) {
schema = tableName.schema;
tableName = tableName.tableName;
}
var sql = this.QueryGenerator.describeTableQuery(tableName, schema, schemaDelimiter);
return this.sequelize.query(sql, { type: QueryTypes.DESCRIBE }).then(function(data) {
return this.sequelize.query(sql, undefined, { type: QueryTypes.DESCRIBE, logging: options && options.logging }).then(function(data) {
// If no data is returned from the query, then the table name may be wrong.
// Query generators that use information_schema for retrieving table info will just return an empty result set,
// it will not throw an error like built-ins do (e.g. DESCRIBE on MySql).
......@@ -704,7 +703,7 @@ module.exports = (function() {
options.plain = options.plain === undefined ? true : options.plain;
var sql = this.QueryGenerator.selectQuery(tableName, options, Model)
, queryOptions = Utils._.extend({ transaction: options.transaction, plain: options.plain }, { raw: true, type: QueryTypes.SELECT });
, queryOptions = Utils._.extend({ transaction: options.transaction, plain: options.plain, logging: options.logging }, { raw: true, type: QueryTypes.SELECT });
if (attributeSelector === undefined) {
throw new Error('Please pass an attribute selector!');
......@@ -835,7 +834,7 @@ module.exports = (function() {
var sql = this.QueryGenerator.setAutocommitQuery(value, options);
if (sql) {
return this.sequelize.query(sql, null, { transaction: transaction });
return this.sequelize.query(sql, null, { transaction: transaction, logging: options.logging });
} else {
return Promise.resolve();
}
......@@ -853,7 +852,7 @@ module.exports = (function() {
var sql = this.QueryGenerator.setIsolationLevelQuery(value, options);
if (sql) {
return this.sequelize.query(sql, null, { transaction: transaction });
return this.sequelize.query(sql, null, { transaction: transaction, logging: options.logging });
} else {
return Promise.resolve();
}
......
......@@ -382,17 +382,16 @@ if (dialect.match(/^postgres/)) {
return User.sync({
logging: function (sql) {
console.log(sql);
if (sql.indexOf('neutral') > -1) {
expect(sql).to.equal("ALTER TYPE \"enum_UserEnums_mood\" ADD VALUE 'neutral' BEFORE 'happy'");
expect(sql.indexOf("ALTER TYPE \"enum_UserEnums_mood\" ADD VALUE 'neutral' BEFORE 'happy'")).to.not.be.equal(-1);
count++;
}
else if (sql.indexOf('ecstatic') > -1) {
expect(sql).to.equal("ALTER TYPE \"enum_UserEnums_mood\" ADD VALUE 'ecstatic' BEFORE 'meh'");
expect(sql.indexOf("ALTER TYPE \"enum_UserEnums_mood\" ADD VALUE 'ecstatic' BEFORE 'meh'")).to.not.be.equal(-1);
count++;
}
else if (sql.indexOf('joyful') > -1) {
expect(sql).to.equal("ALTER TYPE \"enum_UserEnums_mood\" ADD VALUE 'joyful' AFTER 'meh'");
expect(sql.indexOf("ALTER TYPE \"enum_UserEnums_mood\" ADD VALUE 'joyful' AFTER 'meh'")).to.not.be.equal(-1);
count++;
}
}
......
......@@ -1586,7 +1586,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return this.User.count({
logging: function (sql) {
test = true;
expect(sql).not.to.exist;
expect(sql).to.exist;
expect(sql.toUpperCase().indexOf('SELECT')).to.be.above(-1);
}
}).then(function() {
......@@ -1679,7 +1679,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return this.UserWithAge.min('age', {
logging: function (sql) {
test = true;
expect(sql).not.to.exist;
expect(sql).to.exist;
expect(sql.toUpperCase().indexOf('SELECT')).to.be.above(-1);
}
}).then(function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!