Fixed/Improved mysql escaping in the fields names

This commit is contained in:
redvulps 2011-11-22 20:43:05 -02:00
parent f51990949f
commit 8b67c8d92e
1 changed files with 1 additions and 11 deletions

View File

@ -66,17 +66,7 @@ MySQL.prototype.toFields = function (model, data) {
var props = this._models[model].properties;
Object.keys(data).forEach(function (key) {
if (props[key]) {
if(key.indexOf('.') != -1) {
keys = key.split('.');
for(var item = 0; item < keys.length; item++) {
keys[item] = '`' + keys[item] + '`';
}
key = keys.join('.');
}
fields.push('`' + key + '` = ' + this.toDatabase(props[key], data[key]));
fields.push('`' + key.replace(/\./g, '`.`') + '` = ' + this.toDatabase(props[key], data[key]));
}
}.bind(this));
return fields.join(',');