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

Commit 54776221 by Mick Hansen

Merge pull request #1617 from seegno/refactor-pg-query

Normalize isInsertQuery and isUpdateQuery
2 parents 39eb4dff 4a04f934
Showing with 2 additions and 15 deletions
...@@ -144,23 +144,10 @@ module.exports = (function() { ...@@ -144,23 +144,10 @@ module.exports = (function() {
} }
} else if (this.send('isShowOrDescribeQuery')) { } else if (this.send('isShowOrDescribeQuery')) {
this.emit('success', results) this.emit('success', results)
} else if (this.send('isInsertQuery')) {
if (this.callee !== null) { // may happen for bulk inserts
for (var key in rows[0]) {
if (rows[0].hasOwnProperty(key)) {
var record = rows[0][key]
if (!!this.callee.Model && !!this.callee.Model.rawAttributes && !!this.callee.Model.rawAttributes[key] && !!this.callee.Model.rawAttributes[key].type && this.callee.Model.rawAttributes[key].type.toString() === DataTypes.HSTORE.toString()) {
record = hstore.parse(record)
}
this.callee.dataValues[key] = record
}
}
}
this.emit('success', this.callee)
} else if ([QueryTypes.BULKUPDATE, QueryTypes.BULKDELETE].indexOf(this.options.type) !== -1) { } else if ([QueryTypes.BULKUPDATE, QueryTypes.BULKDELETE].indexOf(this.options.type) !== -1) {
this.emit('success', result.rowCount) this.emit('success', result.rowCount)
} else if (this.send('isUpdateQuery')) { } else if (this.send('isInsertQuery') || this.send('isUpdateQuery')) {
if (this.callee !== null) { // may happen for bulk updates if (this.callee !== null) { // may happen for bulk inserts or bulk updates
for (var key in rows[0]) { for (var key in rows[0]) {
if (rows[0].hasOwnProperty(key)) { if (rows[0].hasOwnProperty(key)) {
var record = rows[0][key] var record = rows[0][key]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!