From 667953fd5c8d608e617197f1e645de7bb003fdde Mon Sep 17 00:00:00 2001 From: Muhammad Raihan Muhaimin Date: Tue, 7 Jun 2016 17:04:52 -0400 Subject: [PATCH] Proper error message for undefined where options (#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. --- lib/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/utils.js b/lib/utils.js index ff6b226f..177ae97b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -48,6 +48,9 @@ var prepareValue = function(val, seen) { if(typeof val === 'object') { return prepareObject(val, seen); } + if (typeof val === 'undefined') { + throw new Error('SQL queries with undefined where clause option'); + } return val.toString(); };