Merge pull request #19 from vectart/master

Prevent inserting undefined values
This commit is contained in:
Raymond Feng 2014-03-21 08:46:09 -07:00
commit f6a370921d
1 changed files with 7 additions and 3 deletions

View File

@ -215,9 +215,13 @@ MySQL.prototype.updateOrCreate = function (model, data, callback) {
} else { } else {
v = data[key]; v = data[key];
} }
fieldsNames.push(k); if (v !== undefined) {
fieldValues.push(v); fieldsNames.push(k);
if (!mysql.id(model, key)) combined.push(k + ' = ' + v); fieldValues.push(v);
if (!mysql.id(model, key)) {
combined.push(k + ' = ' + v);
}
}
} }
}); });