Problem/Motivation
If a base field on an entity's base table is used as a filter criteria, there are no operator choices for "Is empty (NULL)" and "Is not empty (NOT NULL)".
I discovered this with a custom entity when I wanted to find null values. The only example I can find in core uses the file entity.
Steps to reproduce
- Create a view for files.
- Add a filter criteria. Select filename as the field.
- Note that "Is empty (NULL)" and "Is not empty (NOT NULL)" do not appear in the operator selection.
Proposed resolution
Make "Is empty (NULL)" and "Is not empty (NOT NULL)" options available on Views UI filters for all Not Required fields.
Remaining tasks
Code review
User interface changes
"Is empty (NULL)" and "Is not empty (NOT NULL)" options available on Views UI filters for all Not Required fields.
Before:
After MR Solution:
API changes
None
Data model changes
None
Original description
I'm not quite sure if this should be a bug or a feature request.
If a base field on an entity's base table is used as a filter criteria, there are no operator choices for "Is empty (NULL)" and "Is not empty (NOT NULL)".
I discovered this with a custom entity when I wanted to find null values. The only example I can find in core uses the file entity.
Steps to reproduce.
- Create a view for files.
- Add a filter criteria. Select filename as the field.
- Note that "Is empty (NULL)" and "Is not empty (NOT NULL)" do not appear in the operator selection.
I think it is a reasonable expectation to be able to search for null and not null. I know "allow empty" can be added per entity in a views_data handler or a hook_views_data or hook_views_data_alter but is there any reason this shouldn't be added automatically?