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

Commit c75ff9ef by Sascha Depold

use the db method getter

1 parent b968ba36
Showing with 3 additions and 7 deletions
...@@ -28,7 +28,7 @@ module.exports = (function() { ...@@ -28,7 +28,7 @@ module.exports = (function() {
var columnTypes = {}; var columnTypes = {};
this.database.serialize(function() { this.database.serialize(function() {
var executeSql = function() { var executeSql = function() {
self.database[databaseMethod](self.sql, function(err, results) { self.database[getDatabaseMethod.call(self)](self.sql, function(err, results) {
//allow clients to listen to sql to do their own logging or whatnot //allow clients to listen to sql to do their own logging or whatnot
self.emit('sql', self.sql) self.emit('sql', self.sql)
this.columnTypes = columnTypes; this.columnTypes = columnTypes;
...@@ -36,11 +36,7 @@ module.exports = (function() { ...@@ -36,11 +36,7 @@ module.exports = (function() {
}) })
}; };
var isInsertCommand = (self.sql.toLowerCase().indexOf('insert') == 0) if (getDatabaseMethod.call(self) === 'all' && /select\s.*?\sfrom\s+([^ ;]+)/i.test(self.sql)) {
, 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; var tableName = RegExp.$1;
if (tableName !== 'sqlite_master') { if (tableName !== 'sqlite_master') {
// get the column types // get the column types
...@@ -65,7 +61,6 @@ module.exports = (function() { ...@@ -65,7 +61,6 @@ module.exports = (function() {
//private //private
var onSuccess = function(results, metaData) {
var getDatabaseMethod = function() { var getDatabaseMethod = function() {
if (this.send('isInsertQuery') || this.send('isUpdateQuery')) { if (this.send('isInsertQuery') || this.send('isUpdateQuery')) {
return 'run' return 'run'
...@@ -74,6 +69,7 @@ module.exports = (function() { ...@@ -74,6 +69,7 @@ module.exports = (function() {
} }
} }
var onSuccess = function(results, metaData) {
var result = this.callee var result = this.callee
, self = this , self = this
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!