Prevent inserting undefined values
The following SQL query was executed: INSERT INTO `cv` (`first_name`, `last_name`, `father_name`, `city`, `district`, `transfer`, `nationality`, `email`, `icq`, `skype`, `birth_date`, `marital_status`, `gender`, `children_status`, `id`) VALUES ('asdsd', , , '', '', , , 'i@marat.by', , , , , , , 2) ON DUPLICATE KEY UPDATE `first_name` = 'asdsd', `last_name` = undefined, `father_name` = undefined, `city` = '', `district` = '', `transfer` = undefined, `nationality` = undefined, `email` = 'i@marat.by', `icq` = undefined, `skype` = undefined, `birth_date` = undefined, `marital_status` = undefined, `gender` = undefined, `children_status` = undefined;
This commit is contained in:
parent
177207d6a5
commit
91116f32db
10
lib/mysql.js
10
lib/mysql.js
|
@ -215,9 +215,13 @@ MySQL.prototype.updateOrCreate = function (model, data, callback) {
|
|||
} else {
|
||||
v = data[key];
|
||||
}
|
||||
fieldsNames.push(k);
|
||||
fieldValues.push(v);
|
||||
if (!mysql.id(model, key)) combined.push(k + ' = ' + v);
|
||||
if (v !== undefined) {
|
||||
fieldsNames.push(k);
|
||||
fieldValues.push(v);
|
||||
if (!mysql.id(model, key)) {
|
||||
combined.push(k + ' = ' + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue