1602 / jugglingdb

Multi-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
http://1602.github.io/jugglingdb/
2.04k stars 241 forks source link

ReferenceError: data is not defined in jugglingdb/lib/sql.js:49 #361

Closed dvdbng closed 10 years ago

dvdbng commented 10 years ago

With the recent update (v0.2.9), I get this error.

The code doesn't appear to be in the repository, but the function goes like this

BaseSQL.prototype.escapeId = function(id) {
    if (this.schema.settings.slave) {
        return '"' + id.toString().replace(/["\n]/g, '') + '"';
    } else {
        var idNumber = Number(data.id);
        if (isNaN(idNumber)) {
            throw new Error('id is not a number');
        }
        return idNumber;
    }
}

And changing var idNumber = Number(data.id); for var idNumber = Number(id); works

dvdbng commented 10 years ago

(Also, a semi colon at the end of the function would be nice to keep JSHint quiet)