Fix find with NaN id in base-sql
This commit is contained in:
parent
e13149edc5
commit
8099f7edf2
|
@ -62,8 +62,12 @@ BaseSQL.prototype.exists = function (model, id, callback) {
|
|||
};
|
||||
|
||||
BaseSQL.prototype.find = function find(model, id, callback) {
|
||||
var idNumber = Number(id);
|
||||
if (isNaN(idNumber)) {
|
||||
callback(new Error('id is not a number'));
|
||||
}
|
||||
var sql = 'SELECT * FROM ' +
|
||||
this.tableEscaped(model) + ' WHERE ' + this.escapeName('id') + ' = ' + Number(id) + ' LIMIT 1';
|
||||
this.tableEscaped(model) + ' WHERE ' + this.escapeName('id') + ' = ' + idNumber + ' LIMIT 1';
|
||||
|
||||
this.query(sql, function (err, data) {
|
||||
if (data && data.length === 1) {
|
||||
|
|
Loading…
Reference in New Issue