I came across a need to create dynamic orm filtering on a given query.
I.e, given some input dictionary:
{"orm_entitiy":"City", attribute":"id","op":">","value":"1"}
and an existing query object query
Will need to evaluate to: new_filtered_query = query.filter(City.id > 1)
My questions are:
1. Are you familiar with some mature library which solves this need?
2. I saw a solution in SO and a blog, but I have a difficulty to understand the section:
attr = list(filter(
lambda e: hasattr(column, e % op),
['%s', '%s_', '__%s__']
))[0] % op
Could someone please describe the logic behind this in details?