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

Commit d2e9adcb by Martin Aspeli

Rebase onto sequelize master and reflect MySQL query generator refactoring there

1 parent 3b951e13
......@@ -244,8 +244,7 @@ module.exports = (function() {
},
bulkInsertQuery: function(tableName, attrValueHashes) {
var query = "INSERT INTO <%= table %> (<%= attributes %>) VALUES <%= tuples %>;"
, tuples = []
var tuples = []
Utils._.forEach(attrValueHashes, function(attrValueHash) {
tuples.push("(" +
......@@ -255,13 +254,12 @@ module.exports = (function() {
")")
})
var replacements = {
table: QueryGenerator.addQuotes(tableName),
attributes: Object.keys(attrValueHashes[0]).map(function(attr){return QueryGenerator.addQuotes(attr)}).join(","),
tuples: tuples.join(",")
}
var table = QueryGenerator.addQuotes(tableName)
var attributes = Object.keys(attrValueHashes[0]).map(function(attr){return QueryGenerator.addQuotes(attr)}).join(",")
return Utils._.template(query)(replacements)
var query = "INSERT INTO " + table + " (" + attributes + ") VALUES " + tuples.join(",") + ";"
return query
},
updateQuery: function(tableName, attrValueHash, where) {
......@@ -306,13 +304,12 @@ module.exports = (function() {
bulkDeleteQuery: function(tableName, where, options) {
options = options || {}
var query = "DELETE FROM <%= table %> WHERE <%= where %>"
var replacements = {
table: QueryGenerator.addQuotes(tableName),
where: QueryGenerator.getWhereConditions(where)
}
var table = QueryGenerator.addQuotes(tableName)
var where = QueryGenerator.getWhereConditions(where)
return Utils._.template(query)(replacements)
var query = "DELETE FROM " + table + " WHERE " + where
return query
},
incrementQuery: function (tableName, attrValueHash, where) {
......
......@@ -118,6 +118,7 @@ module.exports = (function() {
this.callee[key] = record
}
}
}
this.emit('success', this.callee)
} else if (this.send('isUpdateQuery')) {
......@@ -131,6 +132,7 @@ module.exports = (function() {
this.callee[key] = record
}
}
}
this.emit('success', this.callee)
} else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!