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
{"foo":[1,2,3]}
This query will match the above simple object:
app_tables.my_table.get(simple_obj={"foo":[1,2]})
This query will not:
app_tables.my_table.get(simple_obj={"foo":[1,2,3,4]})
If you have two similar simple objects in your DataTable, such as:
# simple objects in a DataTable
{"foo":[1,2,3,4]}
{"foo":[1,2,3]}
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.