Problem/Motivation

Since #3343250: Make date filter inclusive, SearchApiDate::opBetween() adds "+1 day" to the max date in any between condition where the max value does not have an explicit time.
I must say I find this pretty confusing because the between condition now behaves differently for SQL views and search_api views. It also makes it hard to configure an exclusive between condition.

But there is a use case where it feels particularly wrong: when using an offset value.
If I create a between condition with min = -90 days and max = now, it will generate a query where the max is "now +1 day" (so tomorrow at the same time), which is obviously not what I want here.

Steps to reproduce

Create a search_api view.
Add a condition on a date field with the between operator, with values min = -90 days and max = now.
The views displays content with a date value in the future.

Proposed resolution

SearchApiDate::opBetween() should not add "+1 day" to offset values.

Issue fork search_api-3465288

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prudloff created an issue. See original summary.

prudloff’s picture

Status: Active » Needs review
prudloff’s picture

drunken monkey’s picture

Component: General code » Views integration
Status: Needs review » Fixed

Makes sense, thanks a lot!
Merging.

drunken monkey’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.