Skip to content

Commit 26f5ead

Browse files
authored
Merge pull request #6 from richmolj/master
Ensure `false` can be passed in `where` clause
2 parents e2c041d + 1b5393a commit 26f5ead

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/util/parameterize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default function parameterize(obj : any, prefix? : string) : string {
44
for (let key in obj) {
55
let value = obj[key];
66

7-
if (!!value) {
7+
if (value !== undefined && value !== null && value !== '') {
88
if (prefix) {
99
key = `${prefix}[${key}]`;
1010
}

test/integration/finders-test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,26 @@ describe('Model finders', function() {
260260
});
261261
});
262262

263+
describe('when value is false', function() {
264+
before(function () {
265+
fetchMock.reset();
266+
fetchMock.get('http://example.com/api/v1/people?filter[id]=2&filter[a]=false', {
267+
data: [
268+
{ id: '2', type: 'people' }
269+
]
270+
});
271+
});
272+
273+
it('still queries correctly', function(done) {
274+
resultData(Person.where({ id: 2 }).where({ a: false }).all()).then((data) => {
275+
expect(data.length).to.eq(1);
276+
expect(data[0]).to.be.instanceof(Person);
277+
expect(data[0]).to.have.property('id', '2');
278+
done();
279+
});
280+
});
281+
});
282+
263283
describe('when merging association #where', function() {
264284
before(function () {
265285
fetchMock.reset();

0 commit comments

Comments
 (0)