From 6f69538d713f5bdfdd4f2c0d2fbb761898b6e30f Mon Sep 17 00:00:00 2001 From: alxndrsn <@alxndrsn> Date: Fri, 22 Mar 2019 09:36:37 +0000 Subject: [PATCH] Don't ignore undefined keys in where clauses 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..ecd61d57f 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]; + branch[key] = null; } });