diff --git a/Makefile b/Makefile index b2a610a..4784f5e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ +.PHONY: test test-unit install test-integration + ROOT=$(shell pwd) +install: + npm install + test: test-unit test-unit: @@ -12,4 +17,4 @@ test-integration: ln -s $(ROOT) node_modules/sails-postgresql/node_modules/waterline-sequel rm -rf node_modules/sails-mysql/node_modules/waterline-sequel ln -s $(ROOT) node_modules/sails-mysql/node_modules/waterline-sequel - @NODE_ENV=test node test/integration/runnerDispatcher.js \ No newline at end of file + @NODE_ENV=test node test/integration/runnerDispatcher.js diff --git a/sequel/lib/criteriaProcessor.js b/sequel/lib/criteriaProcessor.js index be2cb51..2fcffdc 100644 --- a/sequel/lib/criteriaProcessor.js +++ b/sequel/lib/criteriaProcessor.js @@ -830,6 +830,11 @@ CriteriaProcessor.prototype.prepareCriterion = function prepareCriterion(key, va } break; + + default: + var err = new Error('Unknown filtering operator: "' + key + "\". Should be 'startsWith', '>', 'contains' or similar"); + err.operator = key; + throw err; } // Bump paramCount diff --git a/test/unit/index.test.js b/test/unit/index.test.js index dce209d..c16a168 100644 --- a/test/unit/index.test.js +++ b/test/unit/index.test.js @@ -82,6 +82,14 @@ describe('Sequel', function () { }); }); + describe('queries with an unknown operator', function () { + it('throws an error when the operator is unknown', function() { + var sequel = new Sequel(schema); + assert.throws(sequel.find.bind(sequel, 'bar', { id: { 'in': [ 1, 2 ] } }), + Error, "Unknown filtering operator: \"in\". Should be 'startsWith', '>', 'contains' or similar"); + }); + }); + describe('.find() with schema name', function () { var _options = _.extend({}, options, {schemaName: {'foo':'myschema','oddity':'anotherschema','bat':'public'}}); // Loop through the query objects and test them against the `.find()` method. @@ -99,5 +107,5 @@ describe('Sequel', function () { done(); }); }); - }); + }); });