fix finding null values
This commit is contained in:
parent
91a59fa5ad
commit
8647faa5a9
|
@ -13,7 +13,12 @@ function wrap(db, dir, dbsMap) {
|
|||
}
|
||||
|
||||
db.escape = function (str) {
|
||||
return (str||'').toString().replace(/'/g, "''");
|
||||
// TODO? literals for true,false,null
|
||||
// error on undefined?
|
||||
if (undefined === str) {
|
||||
str = '';
|
||||
}
|
||||
return String(str).replace(/'/g, "''");
|
||||
};
|
||||
|
||||
function lowerFirst(str) {
|
||||
|
@ -233,10 +238,13 @@ function wrap(db, dir, dbsMap) {
|
|||
sql += 'AND ';
|
||||
}
|
||||
if (null === obj[key]) {
|
||||
sql += db.escape(snakeCase(key)) + " IS '" + db.escape(obj[key]) + "'";
|
||||
sql += db.escape(snakeCase(key)) + " IS null";
|
||||
}
|
||||
else {
|
||||
sql += db.escape(snakeCase(key)) + " = '" + db.escape(obj[key]) + "'";
|
||||
// TODO check that key is some type? ignore undefined?
|
||||
if (undefined === obj[key]) {
|
||||
sql += db.escape(snakeCase(key)) + " = '" + db.escape(obj[key]) + "'";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue