fix created_date/modified_date relative date filter searches #16287
+40
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
There are two problems when using relative date filters that don't define both a begin and end date. E.g. "To end of previous year" or "From start of current week", as opposed to those that define a begin AND end date - e.g. "This month".
Before
SQL would be generated incorrectly, resulting in a syntax error.
After fixing this, I also noticed that there was a copy/paste error - when a start date but no end date is defined, the end date (always
NULL
) is used as the start date.After
No syntax error in SQL.
Technical Details
The
if
statement that has the commentSpecial handling for contact table as it has a known alias in advanced search.
was previously only invoked when both start and end dates are defined. I pulled it out to run a bit sooner, and also to run on the$secondWhere
variable.