Unexpected results of conditions, careful!

Bubble gives very strange results when you try to evaluate a database field which is empty or on a search with no results.

See the chart below in which I ran most of the comparisons Bubble allowed for several different data types. In all cases the field was empty (no value in it), or the entire database was empty, results were the same:

link to: Editor

Only the comparisons “is empty” make sense to be true, but lots of different comparisons evaluate as true when we might expect they would give an error. I believe this is because Bubble is based on languages that are not “strongly typed” but that’s a rather in-depth topic. Google “truthy / falsey” to find out more.

If you are having strange results when debugging your workflows, this might be the case!

The case of evaluations running on data where no data item exists can be avoided by checking “count>0” on your search results or adding it as an “and” on a condition. Eg. “Search for Products:count > 0 and Search for Products:first item’s Price > 5”

I don’t know how to avoid the case of checking a field who value has not been set other than to ALWAYS INITIALIZE YOUR DATA. In other words, always set a value in every field when creating an item. That advice held true in programming in ancient days. I suppose it still holds true in Bubble.

I’m new to Bubble… more experienced Bubblers please chime in!