Why can I not filter by boolean==false with ignore empty values checked?
I'm facing an issue when querying all records of a table in my database and trying to apply filters. When I use a boolean to filter, it only works if the value is true and has no effect if it's false. I have the ignore empty values option checked. It seems like Xano treats false as an empty value, which doesn't make sense. (It would maybe make sense if it said ignore falsy values)
How can I create a filter that doesn't require an input to be filled but still allows filtering with false?
Screenshots:
Current behavior: Without any filters, around 100 records are returned. When I set property==true, I get 10 records. When I set property==false, I still get 100 records.
Expected behavior: After setting property==false, I should get 100 - 10 = 90 records.
Answers
-
Hello @flagg2,
Can you try testing it with != on the operator and the value being true and check if it returns 90?
-
Hey @flagg2 ! 👋
Welcome to the Xano Community! 🎉
I was able to replicate the issue and get the expected behavior by unchecking the
Ignore Empty Values Field
. I get what you are saying about the boolean false values being treated as empty when they should be treated as false when left unchecked. I'm sending this over to our engineering team for more clarity. Thank you for bringing this up! -
Thank you @Liz Anaya for investigating, please keep me updated if when this gets fixed. Thanks!
-
In Xano, "empty" is false-y. 0, false, undefined: it's all treated as "empty".
To get a mental model for it: a lot of Xano filters and controls are thin wrappers around PHP functions. They borrow their language/idioms. So when it doubt about what Xano means by a term, one can often get clarity by a search looking for the term plus "php" in google.
For example, one can learn more about how PHP looks at "empty" here:Learning how the tools think can be a superpower for cracking the hard parts of no-code products far more quickly. It s a frequent topic on State Change daily office hours and forum discussions where we focus on the hardest 5% of the project.
-
Hey @Ray Deck, thanks for the insight. I thought it would be a language related issue.
Still, I would say it is a very non intuitive behavior, especially for a no code tool.
Additionaly, the problem persists. How do I filter with an optional boolean value?
-
First, I would remove the checkbox. "Ignore all empty" is not the behavior you are looking for, as we have established.
Have you tried testing what you retrieve when you get a null? If so, we have an interesting opportunity to split the query into "true" vs "false or null" -
@Ray Deck thank you so much for chiming in and providing some clarity!
@flagg2, I just tested this, and when I uncheck the "Ignore all empty" box I receive the expected output. Let me know if this works on your end. 😊 I totally see where you're coming from with this not being an intuitive behavior and we'll make sure to take note of this in our feedback log.
-
Hey @Liz Anaya , sorry for the delayed response, I was abroad.
What you showed here works just fine. The problem is that when you now provide a null value to in_stock, you are going to get 0 results, which creates a new issue.
It is therefore still impossible to have an optional filter which accepts the value of false.
The only temporary solution that I see right now is to use string values instead.
-
Hey @flagg2,
Yeah, with the boolean type, only
true
andfalse
are available as values. If left blank when adding a record, it defaults totrue
orfalse
(whichever you prefer).As you mentioned, changing the type to string/text would be a workaround for this.
We'll keep you posted if there are any changes to this behavior of boolean values.
-
Have you tried != true ? 😉
As in (myInput = false AND myFilter != true) OR (myInput = true AND myFilter = true) OR myInput = null -
Anyone found a solution for this? I am still struggling to see a way in which I can extract all the records when a null value is used as input.
-
Hello,
the only solution I was able to find was to use a text input instead of a boolean input. This allows me to have the 3 different options:
- True
- False
- Null (all the above)
Hope it helps!
Ciao
Luigi
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback