Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot filter on boolean type #412

Closed
wpcfan opened this issue Nov 20, 2016 · 4 comments
Closed

cannot filter on boolean type #412

wpcfan opened this issue Nov 20, 2016 · 4 comments

Comments

@wpcfan
Copy link

wpcfan commented Nov 20, 2016

database looks like below, and http://localhost:3000/todos/?completed=true is working, but http://localhost:3000/todos/?completed=false gets an empty array. I am using 0.9.0

{
  "todos": [
    {
      "id": "bf75769b-4810-64e9-d154-418ff2dbf55e",
      "desc": "getting up",
      "completed": false,
      "userId": "1"
    },
    {
      "id": "5894a12f-dae1-5ab0-5761-1371ba4f703e",
      "desc": "have breakfast",
      "completed": true,
      "userId": "2"
    },
    {
      "id": "0d2596c4-216b-df3d-1608-633899c5a549",
      "desc": "go to school",
      "completed": true,
      "userId": "1"
    },
    {
      "id": "0b1f6614-1def-3346-f070-d6d39c02d6b7",
      "desc": "test",
      "completed": false,
      "userId": "2"
    },
    {
      "id": "c1e02a43-6364-5515-1652-a772f0fab7b3",
      "desc": "This is a te",
      "completed": false,
      "userId": "1"
    }
  ],
  "users": [
    {
      "id": "1",
      "username": "wang",
      "password": "1234"
    },
    {
      "id": "2",
      "username": "peng",
      "password": "5678"
    }
  ]
}
@jantrienes
Copy link
Contributor

I were able to reproduce this behaviour. It seems to be an issue with the filtering.

There is a conditional check within /server/router/plural.js that matches for false values and thus excludes the instance from the result list.

See:

if (!elementValue) {

I assume that this check should catch undefined values and exclude them from the filtering. Therefore, replacing it with the following should do the trick.

if (elementValue == null) {
  return
}

@typicode
Copy link
Owner

Should be good in v0.9.1 thanks to @jantrienes PR

@Jaoow
Copy link

Jaoow commented May 12, 2024

Although the issue is closed, I fell into the same problem. To make "true" or "false" work, replace it with "1" (for true) and "0" (for false).

As in the example:

http://localhost:3000/todos/?completed=true

should be:

http://localhost:3000/todos/?completed=1

@typicode
Copy link
Owner

Fixed in v1.0.0-beta.0 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants