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

Commit 9c50f794 by Sascha Depold

added send method + lowercased sql queries before checking of several parts

1 parent a35ed080
Showing with 25 additions and 5 deletions
......@@ -116,6 +116,17 @@ module.exports = (function() {
return this
}
/**
* This function is a wrapper for private methods.
*
* @param {String} fctName The name of the private method.
*
*/
AbstractQuery.prototype.send = function(fctName/*, arg1, arg2, arg3, ...*/) {
var args = Array.prototype.slice.call(arguments).slice(1)
return eval(fctName).apply(this, args)
}
/////////////
// private //
/////////////
......@@ -132,8 +143,8 @@ module.exports = (function() {
var isInsertQuery = function(results) {
var result = !!this.callee
result = result && (this.sql.indexOf('INSERT INTO') === 0)
result = result && results.hasOwnProperty('insertId')
result = result && (this.sql.toLowerCase().indexOf('insert into') === 0)
result = result && !!results && results.hasOwnProperty('insertId')
return result
}
......@@ -145,7 +156,7 @@ module.exports = (function() {
}
var isShowTableQuery = function() {
return (this.sql.indexOf('SHOW TABLES') === 0)
return (this.sql.toLowerCase().indexOf('show tables') === 0)
}
var handleShowTableQuery = function(results) {
......@@ -155,7 +166,11 @@ module.exports = (function() {
}
var isSelectQuery = function() {
return (this.sql.indexOf('SELECT') === 0)
return (this.sql.toLowerCase().indexOf('select') === 0)
}
var isUpdateQuery = function() {
return (this.sql.toLowerCase().indexOf('update') === 0)
}
var handleSelectQuery = function(results) {
......@@ -213,7 +228,12 @@ module.exports = (function() {
}
var isShowOrDescribeQuery = function() {
return (this.sql.indexOf('SHOW') === 0) || (this.sql.indexOf('DESCRIBE') === 0)
var result = false
result = result || (this.sql.toLowerCase().indexOf('show') === 0)
result = result || (this.sql.toLowerCase().indexOf('describe') === 0)
return result
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!