diff --git a/README.md b/README.md index a6e0dde65..5e34887a7 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,14 @@ [![StackOverflow (waterline)](https://img.shields.io/badge/stackoverflow-waterline-blue.svg)]( http://stackoverflow.com/questions/tagged/waterline) [![StackOverflow (sails)](https://img.shields.io/badge/stackoverflow-sails.js-blue.svg)]( http://stackoverflow.com/questions/tagged/sails.js) +# This Fork + +This fork of Waterline changes the following behaviour: + +* an Error is thrown if an `undefined` value is passed to a `WHERE` clause. This change is debated at https://github.com/balderdashy/sails/issues/4639, but currently unresolved + +# Introduction + Waterline is a next-generation storage and retrieval engine, and the default ORM used in the [Sails framework](https://sailsjs.com). It provides a uniform API for accessing stuff from different kinds of [databases and protocols](https://sailsjs.com/documentation/concepts/extending-sails/adapters/available-adapters). That means you write the same code to get and store things like users, whether they live in MySQL, MongoDB, neDB, or Postgres. diff --git a/lib/waterline/utils/query/private/normalize-where-clause.js b/lib/waterline/utils/query/private/normalize-where-clause.js index 8e64c6336..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}`)); } }); @@ -600,7 +597,7 @@ module.exports = function normalizeWhereClause(whereClause, modelIdentity, orm, // Recursive call try { - _recursiveStep(conjunctOrDisjunct, recursionDepth+1, conjunctsOrDisjuncts, i, soleBranchKey === 'or'); + _recursiveStep(conjunctOrDisjunct, recursionDepth+1, conjunctsOrDisjuncts, i); } catch (e) { switch (e.code) { diff --git a/package.json b/package.json index 5be5ce630..f8b8f5314 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "waterline", + "name": "safe-waterline", "description": "An ORM for Node.js and the Sails framework", "version": "0.13.5-0", "homepage": "http://waterlinejs.org", "contributors": [ { "name": "seerepo", - "github": "https://github.com/balderdashy/waterline/graphs/contributors" + "github": "https://github.com/alxndrsn/waterline/graphs/contributors" } ], "dependencies": { @@ -37,7 +37,7 @@ "sails", "sails.js" ], - "repository": "git://github.com/balderdashy/waterline.git", + "repository": "git://github.com/alxndrsn/waterline.git", "main": "./lib/waterline", "scripts": { "test": "nodever=`node -e \"console.log('\\`node -v\\`'[1]);\"` && if [ $nodever != \"0\" ]; then npm run lint; fi && npm run custom-tests",