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

Commit 6147c8e8 by Jan Aagaard Meier

Allow logging in individual functions even though the global logging option is false. Closes #2571

1 parent 64960b02
......@@ -6,8 +6,9 @@
- [BUG] `Model#destroy()` now supports `field`, this also fixes an issue with `N:M#removeAssociation` and `field`
- [BUG] Customized error message can now be set for unique constraint that was created manually (not with sync, but e.g. with migrations) or that has fields with underscore naming. This was problem at least with postgres before.
- [BUG] Fixed a bug where plain objects like `{ in: [...] }` were not properly converted to SQL when combined with a sequelize method (`fn`, `where` etc.). Closes [#2077](https://github.com/sequelize/sequelize/issues/2077)
- [INTERNALS] Update `inflection` dependency to v1.5.2
- [BUG] Made the default for array search in postgres exact comparison instead of overlap
- [BUG] Allow logging from individual functions even though the global logging setting is false. Closes [#2571](https://github.com/sequelize/sequelize/issues/2571)
- [INTERNALS] Update `inflection` dependency to v1.5.2
#### Backwards compatability changes
- When eager-loading a many-to-many association, the attributes of the through table are now accessible through an attribute named after the through model rather than the through table name singularized. i.e. `Task.find({include: Worker})` where the table name for through model `TaskWorker` is `TableTaskWorkers` used to produce `{ Worker: { ..., TableTaskWorker: {...} } }`. It now produces `{ Worker: { ..., TaskWorker: {...} } }`. Does not affect models where table name is auto-defined by Sequelize, or where table name is model name pluralized.
......
......@@ -26,9 +26,7 @@ module.exports = (function() {
Query.prototype.run = function(sql) {
this.sql = sql;
if (this.options.logging !== false) {
this.sequelize.log('Executing (' + this.client.uuid + '): ' + this.sql);
}
this.sequelize.log('Executing (' + this.client.uuid + '): ' + this.sql, this.options);
var resultSet = [],
errorDetected = false,
......
......@@ -26,9 +26,7 @@ module.exports = (function() {
var self = this;
this.sql = sql;
if (this.options.logging !== false) {
this.sequelize.log('Executing (' + (this.connection.uuid || 'default') + '): ' + this.sql);
}
this.sequelize.log('Executing (' + (this.connection.uuid || 'default') + '): ' + this.sql, this.options);
var promise = new Utils.Promise(function(resolve, reject) {
self.connection.query(self.sql, function(err, results, fields) {
......
......@@ -50,9 +50,7 @@ module.exports = (function() {
, query = this.client.query(sql)
, rows = [];
if (this.options.logging !== false) {
this.sequelize.log('Executing (' + (this.client.uuid || 'default') + '): ' + this.sql);
}
this.sequelize.log('Executing (' + (this.client.uuid || 'default') + '): ' + this.sql, this.options);
var promise = new Promise(function(resolve, reject) {
query.on('row', function(row) {
......
......@@ -30,9 +30,7 @@ module.exports = (function() {
this.sql = sql;
if (this.options.logging !== false) {
this.sequelize.log('Executing (' + (this.database.uuid || 'default') + '): ' + this.sql);
}
this.sequelize.log('Executing (' + (this.database.uuid || 'default') + '): ' + this.sql, this.options);
promise = new Utils.Promise(function(resolve) {
var columnTypes = {};
......
......@@ -981,15 +981,23 @@ module.exports = (function() {
};
Sequelize.prototype.log = function() {
var args = [].slice.call(arguments);
var args = [].slice.call(arguments)
, last = Utils._.last(args)
, options;
if (this.options.logging) {
if (this.options.logging === true) {
if (last && Utils._.isPlainObject(last) && last.hasOwnProperty('logging')) {
options = last;
} else {
options = this.options;
}
if (options.logging) {
if (options.logging === true) {
console.log('DEPRECATION WARNING: The logging-option should be either a function or false. Default: console.log');
this.options.logging = console.log;
options.logging = console.log;
}
this.options.logging.apply(null, args);
options.logging.apply(null, args);
}
};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!