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) {
|
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) {
|
function lowerFirst(str) {
|
||||||
|
@ -233,11 +238,14 @@ function wrap(db, dir, dbsMap) {
|
||||||
sql += 'AND ';
|
sql += 'AND ';
|
||||||
}
|
}
|
||||||
if (null === obj[key]) {
|
if (null === obj[key]) {
|
||||||
sql += db.escape(snakeCase(key)) + " IS '" + db.escape(obj[key]) + "'";
|
sql += db.escape(snakeCase(key)) + " IS null";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// TODO check that key is some type? ignore undefined?
|
||||||
|
if (undefined === obj[key]) {
|
||||||
sql += db.escape(snakeCase(key)) + " = '" + db.escape(obj[key]) + "'";
|
sql += db.escape(snakeCase(key)) + " = '" + db.escape(obj[key]) + "'";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (null !== obj || (params && !params.limit)) {
|
else if (null !== obj || (params && !params.limit)) {
|
||||||
|
|
Loading…
Reference in New Issue