New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add a way to always include null in the date filter #1928
feature: add a way to always include null in the date filter #1928
Conversation
@@ -33,6 +33,7 @@ class DateFilter extends AbstractContextAwareFilter | |||
const EXCLUDE_NULL = 'exclude_null'; | |||
const INCLUDE_NULL_BEFORE = 'include_null_before'; | |||
const INCLUDE_NULL_AFTER = 'include_null_after'; | |||
const ALWAYS_INCLUDE_NULL = 'always_include_null'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INCLUDE_NULL
only maybe to be more inline with the existing options name ?
@@ -190,7 +191,8 @@ protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterf | |||
$queryBuilder->andWhere($baseWhere); | |||
} elseif ( | |||
(\in_array($operator, [self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true) && self::INCLUDE_NULL_BEFORE === $nullManagement) || | |||
(\in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true) && self::INCLUDE_NULL_AFTER === $nullManagement) | |||
(\in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true) && self::INCLUDE_NULL_AFTER === $nullManagement) || | |||
(\in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER, self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true) && self::ALWAYS_INCLUDE_NULL === $nullManagement) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe invert the conditions as the ===
might have a lower cost ?
7cbce65
to
3695f5f
Compare
I'm not sure I understand the purpose of this. Aren't null values already included if you use one of |
Look at the linked issue: The OP wants to include null values always and it seems that doesn't work for now, so it's like a merge of both after and before so it will always includes null values. |
Uhh, yeah I just looked at the issue... Maybe call it |
done |
3695f5f
to
1375b2b
Compare
1375b2b
to
28bbbae
Compare
thanks @Simperfit |
Add a way to always include null values.