Skip to content

Fix GET_MANY in ra-data-json-server data provider returns too many results - #2873

Merged
fzaninotto merged 1 commit into
marmelab:masterfrom
paradoxxxzero:ra-data-json-server-get-many-patch
Feb 15, 2019
Merged

fzaninotto merged 1 commit into
marmelab:masterfrom
paradoxxxzero:ra-data-json-server-get-many-patch

Conversation

@paradoxxxzero

Copy link
Copy Markdown
Contributor

I think using the json-server like feature is not what we want here, since an id_like=2|33|444 will match 2, 33, 444 but also 23, 133 and so forth.
We could restrict the match with delimiters (^ and $) but since it supports multiple filters query, it would be simpler to use just that.

…lter instead of a greedy regular expression.
@fzaninotto

Copy link
Copy Markdown
Member

Are you sure this works? I tested the /posts?id=[1,2] URL on JSONPlaceholder but it doesn't seem to filter the list.

@paradoxxxzero

paradoxxxzero commented Feb 13, 2019 •

Copy link
Copy Markdown
Contributor Author

This is not /posts?id=[1,2] but /posts?id=1&id=2

> const {stringify} = require('query-string')
undefined
> stringify({id: [1, 2]})
'id=1&id=2'

@fzaninotto

Copy link
Copy Markdown
Member

Gotcha, thanks for the explanation.

@fzaninotto fzaninotto changed the title ra-data-json-server: GET_MANY query is too greedy Fix GET_MANY in ra-data-json-server data provider returns too many results Feb 15, 2019
@fzaninotto
fzaninotto merged commit 459ba28 into marmelab:master Feb 15, 2019
@fzaninotto fzaninotto added this to the 2.7.2 milestone Feb 15, 2019
@fzaninotto

Copy link
Copy Markdown
Member

And thanks for the PR!

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

Successfully merging this pull request may close these issues.

2 participants