Contains operator bug

I need some help validating that my premise is correct before submitting a bug. It gets a little detailed, but bear with me.

Here are the relevant link:


Edit: helpexamples | Bubble Editor

Short Description The “contains” operation performs differently when used is a search than when used in a filter.

Setup #1

I have a table called “school” that has fields for “name” and “levels” where levels is a comma separated list of grade levels (e.g. 6,7,8 ). I also have a table called “district” that has fields for “name” and “schools” where schools is a list of “school” things.

I have a page that has a dropdown for district and a dropdown for grade level. I have a repeating group with a data source that is a search for school things with a constraint “levels contains Dropdown Level’s value”

This repeating group IGNORES the district dropdown for the purposes of this test.

Expected Behavior #1 When a specific grade level (e.g. 3) is selected from the grade level dropdown, the repeating group should only bring back school records that have the value 3 in their levels field.

Observed Behavior #1 Works exactly as expected.

Here is the bug part.

Setup #2

Given the same tables/data structure explained above and the same page setup, I also have a second repeating group with a data source that take’s the dropdown district’s value’s school and filters it as “levels contains Dropdown Level’s value”. In other words, it says "given the currently selected district thing, look at the list of school things the district holds and only bring back the ones that have a levels field that contains the selected grade level (e.g. 3).

Expected Behavior #2 When a specific grade level (e.g. 3) is selected from the grade level dropdown, the repeating group should only bring back school records that have the value 3 in their levels field.

Observed Behavior #2 No records are returned.

So despite doing the same thing from a constraint perspective, the contains operator works differently for a search operation than it does for a filter operation.

Anyone see anything wrong with my setup? Anyone else run into this before?



For the record, I know I could do this a different way. For instance, I could create a table called gradeLevel and have it contain all the values (1, 2, 3 etc.) and then have the school thing have a list field called levels, and the contains would work correctly.

That might even be the better way to do it, but the contains should still work consistently IMO.

Hi Marc,

The main issue is that your list of levels should either be a list of texts (or numbers) OR a list of a custom type for grade levels. That level field you had is a single text value, so when you use the “contains” constraint, it’s looking for a matching word within the text string. It’s able to do that in the left RG because you’ve typed out the level numbers with spaces and created “words”.

Moreover, you’re constraining each school at a time. If you’re looking for level 2, the constraint would look like this for each school: does 1,2,3 contain 2? yes. does 4, 5, 6 contain 2? no

With the filtered RG, you’re looking at the full list of school’s levels, so the filter is asking something like: does [1,2,3,4], [5,6,7,8], [9,10,11,12] contain 2? No, it doesn’t. It contains “1,2,3,4” as a single text string for one school, not 2 individually.

I hope that makes sense. So, I added a new field called “level list” that is a list of texts to actually achieve what you’re looking for. I also demonstrated the difference with the two right RGs so that you can see. One of them has this new field in there to do what you want and the other one (far right) is set up to illustrate the difference with a hardcoded value (test it on Hampton District > Roosevelt)

Gaby | Coaching Bubble
Private coaching, courses, and tons of free resources


Gaby, thanks for the reply, but your explanation doesn’t seem to be correct.

In the first repeating group, my search is bringing back a list of schools and saying “look at the levels field for each school in that list and see if it contains a 2”. And it MUST be bringing back a list of schools because the content type of the RG is set to school. And that works fine.

In the second repeating group, my data source said “go look at the district dropdown and bring back the selected district; from within that district, bring me back a list of schools where the levels field contains a 2” And it too must be bring back a list of schools because, once again, the RG content type is school.

It doesn’t make sense to me that the filter would be looking at a full list of school levels and not looking at the field value for each school in the list because the district object does not contain a field that represents a collection of level values. It only contains a collection of school objects.

As proof, I recreated my original second RG that filtered in the district school collection and I went into one of the records and changed the level field from “6, 7, 8” to “6 7 8” (just removed the commas) and the filter on the RG worked fine. I also added a new school “Hoover High” and set the levels value to be “9 10 11 12” (again no commas) and So it must be evaluating the filter individually against each school in the collection. It seems like there is something odd going on in the contains logic.

Hey Marc,

Interesting! So, I discovered that if you add spaces between your original comma separated texts (in the single text value) so that it reads “9 , 10 , 11 , 12” instead of “9,10,11,12”, then your original filter works!

But I agree that it’s a different behavior because the non-spaced one will go through in the constraint version.

This is now twisting my head up. When you originally posted, I agreed that they should be have the same way, but sometimes when you’re filtering expressions, it does take on a different meaning, and the test I did supported my theory, but now that it does work with a single text value (with spaces), I am re-thinking.

Might need to keep mulling on this. Overall though, I think life will be a lot easier if you make the level field an actual list type (of texts or numbers) instead of a single value where you have to be way more careful with syntax of commas and spaces.

EDIT: I also can’t tell if it’s a bug yet or if it’s logic that I’m not seeing clearly.

This topic was automatically closed after 14 days. New replies are no longer allowed.