Problem with filters if filter value is Null
See original GitHub issueNetbox - v3.1.6
pynetbox - 6.5.0
Repeatability I think on all versions.
Let’s look at the request:
https://demo.netbox.dev/api/dcim/racks/?site_id=21&location_id=null
We’ll get racks with no location.
If we try to do the same through the pynetbox library:
pynb.dcim.racks.filter(site_id=21, location_id=None)
Then we get all the racks on this site. The request will look like:
https://demo.netbox.dev/api/dcim/racks/?site_id=21
This applies to both the get request and all objects.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Filter by null or missing attributes - Algolia
Generally speaking, selective filtering becomes a problem when the existence or non-existence of a filter value actually means something. The ...
Read more >Filter on null, blank, or empty values | ThoughtSpot Software
Filtering on NULL and empty values is a special case, and can be tricky if your data contains more than one of these....
Read more >Filter Query ne null doesnt work - Power Platform Community
I had a test on my side, and Filter Query is not valid for filtering null values. You could use Filter array to...
Read more >Bug: Filtering on Null Values - Domo Dojo
We do a lot of "not in" filtering... and when you do that, it not only excludes the records with the value you...
Read more >Javascript Filtering on Null Values - Stack Overflow
Would adding a null check to all of your filters work? So if it is null you return true because you want all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t get why the error says about
vrf
while your.get()
is usingvrf_id
.What does your
vrf
variable contain?Anyway, this is how it looks like here (pynetbox ~6.5.0, NetBox 3.2.0-dev):
I don’t know, I agree it is cleaner, but I also worry it could result in some astonishing behavior for clients. E.g. someone initializing a variable that winds up getting passed to get or filter as None now has very confusing result. I think the current behavior with null is worth calling out in the docs though.