Merge pull request #9 from redvulps/master

Updates to the mysql adapter: wrap fieldnames with `
This commit is contained in:
1602 2011-11-26 02:18:24 -08:00
commit 1f7c6a7ea4
1 changed files with 2 additions and 1 deletions

View File

@ -66,7 +66,7 @@ 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])); fields.push('`' + key.replace(/\./g, '`.`') + '` = ' + this.toDatabase(props[key], data[key]));
} }
}.bind(this)); }.bind(this));
return fields.join(','); return fields.join(',');
@ -90,6 +90,7 @@ MySQL.prototype.toDatabase = function (prop, val) {
].join('-'); ].join('-');
return this.client.escape(val); return this.client.escape(val);
} }
if (prop.type.name == "Boolean") return val ? 1 : 0;
return this.client.escape(val.toString()); return this.client.escape(val.toString());
}; };