Problem/Motivation
The default implementation of Between operator in Date field only applies query condition if both min and max values are specified.
This behavior is not what user would expect if they'd only specify 'from' or 'to' value in exposed form.
This matches core Views behavior, however, there's a bug report in core for this:
#3202489: Expose Date Range Filter with missing min or max returns all results
Once core behavior is changed, Search API should follow it.
Steps to reproduce
1. Create an index with Date field.
2. Create a View with exposed date field filter, configure it to use Between behavior.
3. As a user, open the View page and fill in either Min or Max filter field.
Expected: the filter should apply.
Actual: the filter does not apply.
Proposed resolution
Apply the patch to match Drupal core behavior.
Remaining tasks
Wait for #3202489: Expose Date Range Filter with missing min or max returns all results to land, add tests.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3296477-3--fix_date_between_filter_one_value.patch | 5.31 KB | drunken monkey |
| #4 | 3296477-3--fix_date_between_filter_one_value--tests_only.patch | 2.7 KB | drunken monkey |
Comments
Comment #2
abrammHere's a patch matching behavior seen in core #3202489: Expose Date Range Filter with missing min or max returns all results patches.
Comment #3
drunken monkeyThanks for reporting this issue and already providing a patch! However, did the patch really work for you? I had to also override
acceptExposedInput()to make this work as expected. (Or maybe you just tested it together with the Core patch? I generally like to avoid relying on Core fixes, where possible, since they take forever to get committed, and then it still takes a year or two until we can depend on the Drupal version the fix was committed to.)Attached is a re-roll of your patch, together with the necessary
acceptExposedInput()change and test coverage.Please give it a try or review if you get the chance!
And thanks again in any case!
Comment #4
drunken monkeyComment #6
abrammHi drunken monkey,
Sorry but that was year ago and I can't remember what project this was :). Also I've changed my computer since then and I don't get local projects copies from that time.
I think the patch worked (otherwise, why would I post it here) but there could be some other factors - like, maybe we had BEF there which affected this somehow or probably core patch like you've mentioned. In this case, it sounds reasonable to have this fixed at Search API side without needing core patch.
Appreciate you finding about
acceptExposedInput()and adding tests. I'll check if I can test the patch in nearest time.Comment #8
drunken monkeyHi abramm,
No worries, completely my fault for being so much behind on my issue queues. As there is test coverage, I also don’t think it’s that concerning to not have this patch again verified by you. So, merged it.
Thanks again!
Comment #9
dewalt commentedThe patch is commited, should be the issue closed?
Comment #10
drunken monkeyYes, thanks!