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

Commit 4d5f7f0e by sdepold

refactored show tables handling. it now returns the tableNames instead of objects

1 parent 89c2211d
Showing with 8 additions and 5 deletions
...@@ -61,9 +61,9 @@ module.exports = (function() { ...@@ -61,9 +61,9 @@ module.exports = (function() {
if (this.callee && (this.sql.indexOf('INSERT INTO') == 0) && (results.hasOwnProperty('insertId'))) if (this.callee && (this.sql.indexOf('INSERT INTO') == 0) && (results.hasOwnProperty('insertId')))
this.callee[this.callee.__definition.autoIncrementField] = results.insertId this.callee[this.callee.__definition.autoIncrementField] = results.insertId
// transform results into real model instances
// return the first real model instance if options.plain is set (e.g. Model.find)
if (this.sql.indexOf('SELECT') == 0) { if (this.sql.indexOf('SELECT') == 0) {
// transform results into real model instances
// return the first real model instance if options.plain is set (e.g. Model.find)
if(this.options.raw) { if(this.options.raw) {
result = results result = results
} else { } else {
...@@ -74,11 +74,14 @@ module.exports = (function() { ...@@ -74,11 +74,14 @@ module.exports = (function() {
if(this.options.plain) if(this.options.plain)
result = (result.length == 0) ? null : result[0] result = (result.length == 0) ? null : result[0]
} else if(this.sql.indexOf('SHOW') == 0) {
result = Utils._.flatten(results.map(function(resultSet) {
return Utils._.values(resultSet)
}))
} else if(this.sql.indexOf('DESCRIBE') == 0) {
result = results
} }
if((this.sql.indexOf('SHOW') == 0) || (this.sql.indexOf('DESCRIBE') == 0))
result = results
unbindClient.call(this) unbindClient.call(this)
this.emit('success', result) this.emit('success', result)
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!