Filtering using a custom query, unexpected handling of AND condition
Perhaps my logic is failing me here, but I'm struggling with what I would deem, a very basic function - that is to filter on two boolean fields, whilst allowing NULL. In essence, I have two fields: isActive, isTrial. For my GET API, these fields are both parameters that allow null. My goal is quite simple - allowing a NULL on either field should allow a true or false value to return, whereas specifying a value should ensure only fields with that value is set.
My custom query:
The output as below. I would have expected there to be zero records returned, since there are no records with isActive = false in the database, instead I get ALL records since isTrial is NULL. Instead, it almost seems as if Xano is treating my conditional query as an OR, despite it being clearly configured as an AND? Both fields are in the same table and are not linked to any other tables.
Answers
-
Anybody have an insight into this behaviour? Is this a bug, and if so - can it please be verified from somebody?
-
@aemondis
Ignore empty values doesn't work properly with false booleans. That definitely is a bug.
The solution is to use an enum to represent your true/false values instead of a boolean, if you need to rely on the ignore empty values functionality.
-
Thanks Sean, glad to hear I'm not losing my mind on this! This has been driving me insane for weeks now. I would prefer to avoid changing the DB fields (given there is already data there…), will have a think about how to achieve this.
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