Why can I not filter by boolean==false with ignore empty values checked?

Options

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.

Tagged:

Answers

  • Lefteris - blupry.com
    Options

    Hello @flagg2,

    Can you try testing it with != on the operator and the value being true and check if it returns 90?

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    edited August 2023
    Options

    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!

  • flagg2
    flagg2 Member
    Options

    Thank you @Liz Anaya for investigating, please keep me updated if when this gets fixed. Thanks!

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    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: https://www.php.net/manual/en/function.empty.php

    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.

  • flagg2
    flagg2 Member
    Options

    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?

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    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"

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    Options

    @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.

  • flagg2
    flagg2 Member
    edited August 2023
    Options

    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.

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    edited August 2023
    Options

    Hey @flagg2,

    Yeah, with the boolean type, only true and false are available as values. If left blank when adding a record, it defaults totrue or false (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.

  • MattLaro
    MattLaro Member ✭✭
    edited August 2023
    Options

    Have you tried != true ? 😉

    As in (myInput = false AND myFilter != true) OR (myInput = true AND myFilter = true) OR myInput = null

  • luigi.grossi
    Options

    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.

  • luigi.grossi
    Options

    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:

    1. True
    2. False
    3. Null (all the above)

    Hope it helps!

    Ciao

    Luigi