Budibase / budibase

Low code platform for building business apps and workflows in minutes. Supports PostgreSQL, MySQL, MariaDB, MSSQL, MongoDB, Rest API, Docker, K8s, and more 🚀
https://budibase.com
Other
22.67k stars 1.57k forks source link

Update Setting "Is In" #14605

Closed mikesealey closed 1 month ago

mikesealey commented 1 month ago

Checklist

Hosting SELF & CLOUD

Describe the bug Following a discussion https://github.com/Budibase/budibase/discussions/14604 - the "Update Setting" condition 'Is In" erroneously returns true when compared to an empty string, or a null value

To Reproduce Steps to reproduce the behavior:

  1. Add a headline with text "False"
  2. Add a form with two text fields
  3. Add a condition Update Setting Text to TRUE IF {{ New Form.Fields.this_value }} is in binding {{ New Form.Fields.that_value }}
  4. In preview or published app, add "1" to the first field, and "1,2,3" to the second to see "true" then make the second field empty - it also returns true. "2,3,4" will return false as expected.

The following values should return false, but instead return true - null, "", []

Expected behavior Empty strings, empty text field, empty array, and null should all return "false"

Screenshots See app-export below image

Screencapture https://jam.dev/c/ab9f539d-3b78-40f9-a566-d0c43b5e416d

App Export 14604-export-1726728104323.tar.gz

Desktop (please complete the following information):

Additional context Related: https://github.com/Budibase/budibase/discussions/14604

linear[bot] commented 1 month ago

BUDI-8659 Update Setting "Is In"

aptkingston commented 1 month ago

After reading this I had an inclination that this probably affects all operators rather than just "is in" and it looks like that's correct. The reason for this is due to the "on empty filter" operator which is designed to return all rows when all filters are empty. We use this same code behind the scenes to evaluate conditions, but this behaviour means that when your condition value is "empty" it effectively skips it and returns true.

So this same thing happens if you just do "equals" with an empty value too.

The fix is to ensure that we use "none" for the "on empty filter" parameter of our query when evaluating conditions in the client library. This is an easy fix 👌

aptkingston commented 1 month ago

Threw up a quick fix!