Pass on missing implementation while filtering

The in_() filter isn't implemented yet for relations. Since these are
being used in multiple locations in order to add new attributes to
objects, we ignore the resulting error and allow the filtering to be
applied by the corresponding result_filter hook afterwards.

Change-Id: Ie91656387f7a7e60738a63bc28bf9bd505407cff
Partial-Bug: 1818318
This commit is contained in:
Jens Harbott 2019-12-14 10:25:26 +01:00
parent 7aa33c425b
commit 79cd582084
1 changed files with 7 additions and 1 deletions

View File

@ -196,7 +196,13 @@ def apply_filters(query, model, filters, context=None):
query = query.filter(
or_(*[column == v for v in value]))
else:
query = query.filter(column.in_(value))
# NOTE(frickler): in_() isn't implemented for relations
# yet, let this pass so it can be handled by the
# result_filter hook
try:
query = query.filter(column.in_(value))
except NotImplementedError:
pass
elif key == 'shared' and hasattr(model, 'rbac_entries'):
# translate a filter on shared into a query against the
# object's rbac entries