Skip to content

Commit

Permalink
use incrementQuery from abstract dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Broadstone committed Dec 9, 2014
1 parent b7924c9 commit 93afadd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 62 deletions.
30 changes: 0 additions & 30 deletions lib/dialects/mssql/query-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,36 +203,6 @@ module.exports = (function() {
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) {
// FIXME: temporary until I implement proper schema support
var dequotedTableName = tableName.toString().replace(/['"]+/g, '');
Expand Down
32 changes: 0 additions & 32 deletions lib/dialects/mssql/sql-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,38 +132,6 @@ module.exports = {
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) {
var query = "DELETE FROM <%= table %>";
var replacements = {
Expand Down

0 comments on commit 93afadd

Please sign in to comment.