Skip to content

Commit 667953f

Browse files
mdrmuhaiminbrianc
authored andcommitted
Proper error message for undefined where options (brianc#1022)
When user provides a knex select statement with an undefined options in where clause it is not properly handled an give an ambiguous error message telling `Unhandled rejection TypeError: Cannot read property 'toString' of undefined.` This PR will helpful to users at it will tell them the exact problem.
1 parent edf4e7f commit 667953f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ var prepareValue = function(val, seen) {
4848
if(typeof val === 'object') {
4949
return prepareObject(val, seen);
5050
}
51+
if (typeof val === 'undefined') {
52+
throw new Error('SQL queries with undefined where clause option');
53+
}
5154
return val.toString();
5255
};
5356

0 commit comments

Comments
 (0)