- Issue created by @hga77
- π¬π§United Kingdom hga77
Changed to use
Database::getConnection()->condition()
instead ofnew Condition('OR')
as per https://www.drupal.org/node/3159568 β - π³π±Netherlands Lendude Amsterdam
There are more issues around that try to find a way of dealing with NULL value fields, see #1919834: Field instance got no default value when created in field UI β and the https://www.drupal.org/project/field_defaults β module. That to me is the right solutions if you want to deal with NULL values for fields, not mess with hard to find settings in your Views. See β¨ Views UI should offer a 'Treat NULL values as FALSE' on boolean field filtering to expose the already existing code path for handling this Needs work and all its related issues for boolean fields trying to handle this.
But, if this is something you want to do in Views anyway, this sounds like a reasonable request since it would be hard to do something like this in contrib.
+++ b/core/modules/views/config/schema/views.data_types.schema.yml @@ -756,6 +756,9 @@ views_filter: + include_null: + type: boolean + label: 'Include NULL values' +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -161,6 +161,7 @@ protected function defineOptions() { + 'include_null' => ['default' => FALSE], @@ -843,6 +844,7 @@ protected function buildGroupOptions() { + 'include_null' => FALSE,
This would require an upgrade path to set the default in existing Views.
+++ b/core/modules/views/config/schema/views.data_types.schema.yml --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php --- a/core/modules/views/src/Plugin/views/filter/StringFilter.php +++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
The option is added to the FilterPluginBase but only used in StringFilter, so shouldn't we add it to StringFilter?
Also, this needs tests.
- π§πͺBelgium rp7
Original patch only applied to StringFilter. I expanded it so it also applies to NumericFilter.
This might be a valid reason to leave the option in FilterPluginBase (since it's being questioned in #4).
Upgrade path + test coverage is still TODO. - last update
5 months ago Custom Commands Failed - π¨π¦Canada phot0x
Original patch only applied to NumericFilter and some others, I expanded it so it also applies to Boolean fields.