From 3597eda00da11694ce306d229af31cfeeb4757fe Mon Sep 17 00:00:00 2001 From: alxndrsn <@alxndrsn> Date: Fri, 22 Mar 2019 09:36:37 +0000 Subject: [PATCH] Throw Error on undefined value in WHERE clause Fixes https://github.com/balderdashy/sails/issues/4639 --- .../utils/query/private/normalize-where-clause.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/waterline/utils/query/private/normalize-where-clause.js b/lib/waterline/utils/query/private/normalize-where-clause.js index 2e96b981f..7520c1407 100644 --- a/lib/waterline/utils/query/private/normalize-where-clause.js +++ b/lib/waterline/utils/query/private/normalize-where-clause.js @@ -298,13 +298,10 @@ module.exports = function normalizeWhereClause(whereClause, modelIdentity, orm, // > here, we have to be more forgiving-- both for usability and backwards-compatibility. - // ╔═╗╔╦╗╦═╗╦╔═╗ ╦╔═╔═╗╦ ╦╔═╗ ┬ ┬┬┌┬┐┬ ┬ ╦ ╦╔╗╔╔╦╗╔═╗╔═╗╦╔╗╔╔═╗╔╦╗ ┬─┐┬ ┬┌─┐ - // ╚═╗ ║ ╠╦╝║╠═╝ ╠╩╗║╣ ╚╦╝╚═╗ ││││ │ ├─┤ ║ ║║║║ ║║║╣ ╠╣ ║║║║║╣ ║║ ├┬┘├─┤└─┐ - // ╚═╝ ╩ ╩╚═╩╩ ╩ ╩╚═╝ ╩ ╚═╝ └┴┘┴ ┴ ┴ ┴ ╚═╝╝╚╝═╩╝╚═╝╚ ╩╝╚╝╚═╝═╩╝ ┴└─┴ ┴└─┘ - // Strip out any keys with undefined values. + // Convert undefined keys to null _.each(_.keys(branch), function (key){ if (_.isUndefined(branch[key])) { - delete branch[key]; + throw flaverr('E_CONSTRAINT_WOULD_MATCH_NOTHING', new Error(`Unexpected undefined value in WHERE clause for column: ${key}`)); } });