Skip to content

Commit eca6b76

Browse files
jantrienestypicode
authored andcommitted
fix filter for boolean value false (typicode#412) (typicode#413)
1 parent b5eec15 commit eca6b76

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/server/router/plural.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ module.exports = (db, name) => {
120120
const path = key.replace(/(_lte|_gte|_ne|_like)$/, '')
121121
const elementValue = _.get(element, path)
122122

123-
if (!elementValue) {
123+
if (elementValue == null) {
124124
return
125125
}
126126

test/server/plural.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ describe('Server', () => {
194194
.expect([ db.comments[3] ])
195195
.expect(200, done)
196196
})
197+
198+
it('should support filtering by boolean value false', (done) => {
199+
request(server)
200+
.get('/comments?published=false')
201+
.expect('Content-Type', /json/)
202+
.expect([ db.comments[1], db.comments[2], db.comments[4] ])
203+
.expect(200, done)
204+
})
197205
})
198206

199207
describe('GET /:resource?_end=', () => {

0 commit comments

Comments
 (0)