Updated mysql adapter to support fields that have internal names like "key" or "order"
Updated mysql adapter to support fields that have internal names like "key" or "order"(they will be escaped to "`key`" and "`order`"), also added support in case of query generates fields like "table.field" that will be escaped to "`table`.`field`"
This commit is contained in:
parent
3b2b57eb7b
commit
abde0df35b
|
@ -66,7 +66,17 @@ MySQL.prototype.toFields = function (model, data) {
|
||||||
var props = this._models[model].properties;
|
var props = this._models[model].properties;
|
||||||
Object.keys(data).forEach(function (key) {
|
Object.keys(data).forEach(function (key) {
|
||||||
if (props[key]) {
|
if (props[key]) {
|
||||||
fields.push(key + ' = ' + this.toDatabase(props[key], data[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]));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
return fields.join(',');
|
return fields.join(',');
|
||||||
|
|
Loading…
Reference in New Issue