Hi guys,
Filtering and sorting combined seem to be not working.
My request parameters are the following:
{{host}}/api/node/article?_format=api_json&filter[0][value]=250&filter[0][operator]=CONTAINS&filter[0][field]=title&page[size]=3&page[offset]=0&fields[node--article]=title&sort=title
Basically the query should get me the two articles that contain "250" within its title sorted by title but it is returning all the "article nodes" sorted but not filtered:
{
"data": [
{
"type": "node--article",
"id": "30",
"attributes": {
"title": "250 items"
}
},
{
"type": "node--article",
"id": "12",
"attributes": {
"title": "300 items"
}
},
{
"type": "node--article",
"id": "25",
"attributes": {
"title": "400 items"
}
}
]
}
Steps to reproduce it:
1. build a query with sort and filter indexes.
2. Try to use a filter value that you know only will return certain results.
3. You will get the results sorted but not filtered.
Expected result:
1. The results should be filtered and then sorted:
{
"data": [
{
"type": "node--article",
"id": "30",
"attributes": {
"title": "250 items"
}
},
{
"type": "node--article",
"id": "12",
"attributes": {
"title": "250 other example"
}
}
]
}| Comment | File | Size | Author |
|---|---|---|---|
| #5 | filtering_and_sorting-2792399-5.patch | 576 bytes | gabesullice |
Comments
Comment #2
mpastas commentedComment #3
mpastas commentedComment #4
gabesullice@mpastas, I'm looking into this now. Thanks for the bug report!
Comment #5
gabesulliceThis should fix your issue @mpastas.
I also noticed another bug while working on this, you may need to also apply #2793059: [BUGFIX] Shorthand filter parameters always use the '=' operator.
Comment #6
gabesulliceUpdating title.
Comment #7
dagmarThanks @gabesullice this fixes our issue. I think this may need some tests to get in, right?
Comment #8
gabesullice@dagmar yes :) interested?
Comment #9
gabesulliceUpdating issue title to be in line with the standard mentioned here: https://www.drupal.org/node/2793195#comment-11573427
Comment #10
e0ipsoGood!
Only a nit pick.
Please favor
'over".As suggested by @dagmar we can probably benefit from a test around this.
Comment #11
gabesulliceComment #12
e0ipso@gabesullice would you be working on that follow up? I wouldn't like to defer this to a follow up to have it forgotten in the issue queue.
If you are not taking #2730245: [TASK] Test classes in the Query namespace, can you edit the description so someone new to the project can have enough context and direction (maybe suggest some implementation details) to tackle this.
I'll be merging this.
Comment #14
e0ipsoComment #15
gabesullice@e0ipso I've updated #2730245: [TASK] Test classes in the Query namespace , although I'll probably be the one who takes it eventually ;)