Anvil Community Forum

Query to test for equality of simple objects

As referenced here, I would find it useful to be able to test for the strict equality of simple objects within a DataTables query.

Currently, when you query a simple object column, it matches on subsets. For example:

# a simple object in a DataTable

This query will match the above simple object:


This query will not:


If you have two similar simple objects in your DataTable, such as:

# simple objects in a DataTable

using {"foo":[1,2]} will match on both rows since the values in the dictionary are a subset of the values in the simple object.

All this to say that, as far as I can tell, there is no clean way of testing for strict equality between a dictionary and simple object. In pure Python you can compare dicts directly for equality (dict1==dict2).

Do you think that app_tables.my_table.get(simple_obj=my_dict) should imply a test for equality (since there is an equals sign in the expression)?

Or, do you think it would be worth extending the query operator so that it has either q.equals(), or q.contains() (which would allow the expression above to be used for equality testing)?

I’m sure smarter people than I have thought through this stuff and therefore there is a reason for the current functionality, but I thought I would just make this inquiry/FR in case it would be helpful.