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

Commit a35ed080 by Sascha Depold

added function for the check of the logging option

1 parent 0fd1a934
......@@ -2,9 +2,7 @@ var Utils = require('../../utils')
, CustomEventEmitter = require("../../emitters/custom-event-emitter")
module.exports = (function() {
var AbstractQuery = function(database, sequelize, callee, options) {
}
var AbstractQuery = function(database, sequelize, callee, options) {}
/**
Inherit from CustomEventEmitter
......@@ -26,6 +24,23 @@ module.exports = (function() {
}
/**
* Check the logging option of the instance and print deprecation warnings.
*
* @return {void}
*/
AbstractQuery.prototype.checkLoggingOption = function() {
if(this.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
}
if(this.options.logging == console.log) {
// using just console.log will break in node < 0.6
this.options.logging = function(s) { console.log(s) }
}
}
/**
* High level function that handles the results of a query execution.
*
*
......@@ -101,6 +116,10 @@ module.exports = (function() {
return this
}
/////////////
// private //
/////////////
var queryResultHasJoin = function(results) {
var hasJoin = !!results[0]
......
......@@ -14,16 +14,7 @@ module.exports = (function() {
raw: false
}, options || {})
if(this.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
}
if(this.options.logging == console.log) {
// using just console.log will break in node < 0.6
this.options.logging = function(s) { console.log(s) }
}
this.checkLoggingOption()
this.bindClientFunction = function(err) { onFailure.call(self, err) }
}
......
......@@ -3,8 +3,6 @@ var Utils = require("../../utils")
module.exports = (function() {
var Query = function(client, sequelize, callee, options) {
var self = this
this.client = client
this.sequelize = sequelize
this.callee = callee
......@@ -14,15 +12,7 @@ module.exports = (function() {
raw: false
}, options || {})
if(this.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
}
if(this.options.logging == console.log) {
// using just console.log will break in node < 0.6
this.options.logging = function(s) { console.log(s) }
}
this.checkLoggingOption()
}
Utils.inherit(Query, AbstractQuery)
......
var Utils = require("../../utils")
, AbstractQuery = require('../abstract/query')
module.exports = (function() {
var Query = function(database, sequelize, callee, options) {
this.database = database
......@@ -13,15 +12,7 @@ module.exports = (function() {
raw: false
}, options || {})
if(this.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
}
if(this.options.logging == console.log) {
// using just console.log will break in node < 0.6
this.options.logging = function(s) { console.log(s) }
}
this.checkLoggingOption()
}
Utils.inherit(Query, AbstractQuery)
......@@ -48,6 +39,7 @@ module.exports = (function() {
var isInsertCommand = (self.sql.toLowerCase().indexOf('insert') == 0)
, isUpdateCommand = (self.sql.toLowerCase().indexOf('update') == 0)
, databaseMethod = (isInsertCommand || isUpdateCommand) ? 'run' : 'all'
if (databaseMethod === 'all' && /select\s.*?\sfrom\s+([^ ;]+)/i.test(self.sql)) {
var tableName = RegExp.$1;
if (tableName !== 'sqlite_master') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!