-
Notifications
You must be signed in to change notification settings - Fork 40
feat(queries): include empty values when using "NOT" operator #7477
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR updates the query filtering behavior to include NULL/empty values when using the "NOT" operator, aligning Specify 7 with the historical Specify 6 behavior and user expectations. When applying negated filters, the system now explicitly includes records where the filtered field is NULL or empty.
Key Changes
- Added
null_safe_not()helper function to handle negated predicates with NULL value inclusion - Modified query filter application logic to use the new helper when
negateis True - Preserved existing behavior for non-negated filters
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.
- Create a query with a field using the "NOT" operator with "In", "Contains", or "Equals" on a field that has empty/NULL data (e.g., NOT Equals "some value").
- Execute the query and check that empty/NULL records are included in results and count.
- Test on
v7.11.2.1to confirm empty/NULL records were excluded before the fix.
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.
-
Create a query with a field using the "NOT" operator with "In", "Contains", or "Equals" on a field that has empty/NULL data (e.g., NOT Equals "some value").
-
Execute the query and check that empty/NULL records are included in results and count.
-
Test on v7.11.2.1 to confirm empty/NULL records were excluded before the fix.
No issues found! The Le left image is the current pr and the right image is the test on v7.11.2.1

It looks good to me!
Triggered by 8454454 on branch refs/heads/issue-6446


Fixes part of #6446
Screenshots and examples below are based on a local copy of the
sbmnhizdatabase used for developing an export workflow for their institution.In this example, the main query filter is on the
EnvironmentalProtectionStatusin theDeterminationtable. In this case, we want to return all Collection Object records whereEnvironmentalProtectionStatusdoes NOT contain the word 'endangered'. In the current release (v7.11.2.1), the not operator causes Specify to ignore blank/null values as well, which is not intuitive and does not match the preferable behavior used in Specify 6.Left:

issue-6446(this PR), Right:v7.11.2.1The query built in Specify 6 is as follows:
Critically, this PR aims to match the behavior
or {field}.{table} is nullakin to Specify 6.Checklist
self-explanatory (or properly documented)
Testing instructions
v7.11.2.1to confirm empty/NULL records were excluded before the fix.