Merge "Get rid of double-join to rbac_entries without filter"
This commit is contained in:
commit
fcd47cca6e
|
@ -222,7 +222,6 @@ class CommonDbMixin(object):
|
||||||
elif key == 'shared' and hasattr(model, 'rbac_entries'):
|
elif key == 'shared' and hasattr(model, 'rbac_entries'):
|
||||||
# translate a filter on shared into a query against the
|
# translate a filter on shared into a query against the
|
||||||
# object's rbac entries
|
# object's rbac entries
|
||||||
query = query.outerjoin(model.rbac_entries)
|
|
||||||
rbac = model.rbac_entries.property.mapper.class_
|
rbac = model.rbac_entries.property.mapper.class_
|
||||||
matches = [rbac.target_tenant == '*']
|
matches = [rbac.target_tenant == '*']
|
||||||
if context:
|
if context:
|
||||||
|
@ -249,6 +248,12 @@ class CommonDbMixin(object):
|
||||||
query.session.query(rbac.object_id).
|
query.session.query(rbac.object_id).
|
||||||
filter(is_shared)
|
filter(is_shared)
|
||||||
)
|
)
|
||||||
|
elif (not context or
|
||||||
|
not self.model_query_scope(context, model)):
|
||||||
|
# we only want to join if we aren't using the subquery
|
||||||
|
# and if we aren't already joined because this is a
|
||||||
|
# scoped query
|
||||||
|
query = query.outerjoin(model.rbac_entries)
|
||||||
query = query.filter(is_shared)
|
query = query.filter(is_shared)
|
||||||
for _nam, hooks in six.iteritems(self._model_query_hooks.get(model,
|
for _nam, hooks in six.iteritems(self._model_query_hooks.get(model,
|
||||||
{})):
|
{})):
|
||||||
|
|
Loading…
Reference in New Issue