diff --git a/lib/sql.js b/lib/sql.js index 895dcd05..0a351bfa 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -201,12 +201,8 @@ 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.idColumnEscaped(model) + ' = ' + idNumber + ' LIMIT 1'; + this.tableEscaped(model) + ' WHERE ' + this.idColumnEscaped(model) + ' = ' + id + ' LIMIT 1'; this.query(sql, function (err, data) { if (data && data.length === 1) { @@ -218,16 +214,16 @@ BaseSQL.prototype.find = function find(model, id, callback) { }.bind(this)); }; -BaseSQL.prototype.destroy = function destroy(model, id, callback) { +BaseSQL.prototype.delete = BaseSQL.prototype.destroy = function destroy(model, id, callback) { var sql = 'DELETE FROM ' + - this.tableEscaped(model) + ' WHERE ' + this.escapeName('id') + ' = ' + Number(id); + this.tableEscaped(model) + ' WHERE ' + this.idColumnEscaped(model) + ' = ' + id; this.command(sql, function (err) { callback(err); }); }; -BaseSQL.prototype.destroyAll = function destroyAll(model, callback) { +BaseSQL.prototype.deleteAll = BaseSQL.prototype.destroyAll = function destroyAll(model, callback) { this.command('DELETE FROM ' + this.tableEscaped(model), function (err) { if (err) { return callback(err, []);