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

Commit 93afadd6 by Matt Broadstone

use incrementQuery from abstract dialect

1 parent b7924c95
...@@ -203,36 +203,6 @@ module.exports = (function() { ...@@ -203,36 +203,6 @@ module.exports = (function() {
return query; return query;
}, },
incrementQuery: function(tableName, attrValueHash, where, options, attributes) {
attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, false, options);
for (var key in attributes) {
if (attributes[key].primaryKey && attrValueHash[key]) {
delete attrValueHash[key];
}
attrValueHash[key] += 1;
}
for (key in options) {
if (key === 'allowNull') {
delete options[key];
}
}
if (!Object.keys(attrValueHash).length) {
return '';
//return ['SELECT * FROM ', tableName, 'WHERE', this.getWhereConditions(where) + ';'].join(' ');
}
var query = [
SqlGenerator.incrementSql(tableName, attrValueHash, options),
'WHERE',
this.getWhereConditions(where)
].join(' ') + ';';
return query;
},
showIndexQuery: function(tableName, options) { showIndexQuery: function(tableName, options) {
// FIXME: temporary until I implement proper schema support // FIXME: temporary until I implement proper schema support
var dequotedTableName = tableName.toString().replace(/['"]+/g, ''); var dequotedTableName = tableName.toString().replace(/['"]+/g, '');
......
...@@ -132,38 +132,6 @@ module.exports = { ...@@ -132,38 +132,6 @@ module.exports = {
return Utils._.template(query)(value); return Utils._.template(query)(value);
}, },
incrementSql: function(tableName, attrValueHash, options) {
attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, this.options.omitNull);
var query
, key
, value
, selFields = []
, values = [];
query = 'UPDATE <%= table %> SET <%= values %> OUTPUT <%= selFields %>';
for (key in attrValueHash) {
value = attrValueHash[key];
values.push(quoteIdentifier(key) + '=' + quoteIdentifier(key) + ' + ' + escape(value));
selFields.push('INSERTED.' + quoteIdentifier(key));
}
options = options || {};
for (key in options) {
value = options[key];
values.push(quoteIdentifier(key) + '=' + escape(value));
}
var replacements = {
table: quoteIdentifiers(tableName),
values: values.join(','),
selFields: selFields.join(',')
};
return Utils._.template(query)(replacements);
},
deleteSql: function(tableName) { deleteSql: function(tableName) {
var query = "DELETE FROM <%= table %>"; var query = "DELETE FROM <%= table %>";
var replacements = { var replacements = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!