Skip to content

Commit

Permalink
Allow querying for null values (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl authored Jun 15, 2016
1 parent 33b6b30 commit a9309af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function getWhere(query) {

Object.keys(where).forEach(prop => {
let value = where[prop];
if(value.$nin) {
if(value && value.$nin) {
value = Object.assign({}, value);

value.$notIn = value.$nin;
Expand Down
12 changes: 12 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// jshint expr:true

import assert from 'assert';
import { expect } from 'chai';
import { base, orm, example } from 'feathers-service-tests';
import Sequelize from 'sequelize';
Expand Down Expand Up @@ -74,6 +75,17 @@ describe('Feathers Sequelize Service', () => {
});
});

it('allows querying for null values (#45)', done => {
const name = 'Null test';
people.create({ name }).then(person =>
people.find({ query: { age: null } }).then(people => {
assert.equal(people.length, 1);
assert.equal(people[0].name, name);
assert.equal(people[0].age, null);
}).then(() => people.remove(person.id))
).then(() => done()).catch(done);
});

base(people, _ids, errors);
});
});
Expand Down

0 comments on commit a9309af

Please sign in to comment.