Fix the logical operator check
This commit is contained in:
parent
cdf9956867
commit
5f3c856d2e
|
@ -458,8 +458,9 @@ DataAccessObject._coerce = function (where) {
|
|||
return where;
|
||||
}
|
||||
|
||||
var err;
|
||||
if (typeof where !== 'object' || Array.isArray(where)) {
|
||||
var err = new Error(util.format('The where clause %j is not an object', where));
|
||||
err = new Error(util.format('The where clause %j is not an object', where));
|
||||
err.statusCode = 400;
|
||||
throw err;
|
||||
}
|
||||
|
@ -473,6 +474,10 @@ DataAccessObject._coerce = function (where) {
|
|||
for (var i = 0; i < clauses.length; i++) {
|
||||
self._coerce(clauses[i]);
|
||||
}
|
||||
} else {
|
||||
err = new Error(util.format('The %p operator has invalid clauses %j', p, clauses));
|
||||
err.statusCode = 400;
|
||||
throw err;
|
||||
}
|
||||
return where;
|
||||
}
|
||||
|
|
|
@ -1086,7 +1086,7 @@ describe('DataAccessObject', function () {
|
|||
it('should throw if the where property is not an object', function () {
|
||||
try {
|
||||
// The where clause has to be an object
|
||||
error = err;model._coerce('abc');
|
||||
model._coerce('abc');
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
@ -1096,7 +1096,7 @@ describe('DataAccessObject', function () {
|
|||
it('should throw if the where property is an array', function () {
|
||||
try {
|
||||
// The where clause cannot be an array
|
||||
error = err;model._coerce([
|
||||
model._coerce([
|
||||
{vip: true}
|
||||
]);
|
||||
} catch (err) {
|
||||
|
@ -1108,7 +1108,7 @@ describe('DataAccessObject', function () {
|
|||
it('should throw if the and operator does not take an array', function () {
|
||||
try {
|
||||
// The and operator only takes an array of objects
|
||||
error = err;model._coerce({and: {x: 1}});
|
||||
model._coerce({and: {x: 1}});
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
@ -1118,7 +1118,7 @@ describe('DataAccessObject', function () {
|
|||
it('should throw if the or operator does not take an array', function () {
|
||||
try {
|
||||
// The or operator only takes an array of objects
|
||||
error = err;model._coerce({or: {x: 1}});
|
||||
model._coerce({or: {x: 1}});
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
@ -1128,7 +1128,7 @@ describe('DataAccessObject', function () {
|
|||
it('should throw if the or operator does not take an array of objects', function () {
|
||||
try {
|
||||
// The or operator only takes an array of objects
|
||||
error = err;model._coerce({or: ['x']});
|
||||
model._coerce({or: ['x']});
|
||||
} catch(err) {
|
||||
error = err;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue