diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 6652ff72814d..f2904f989c7b 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -6145,9 +6145,9 @@ def attribute_columns(column_collection, attributes, nesting_level=None): inner_dc = alias(DatasetCollection) inner_dce = alias(DatasetCollectionElement) order_by_columns.append(inner_dce.c.element_index) - q = q.join(inner_dc, inner_dc.c.id == dce.c.child_collection_id).outerjoin( - inner_dce, inner_dce.c.dataset_collection_id == inner_dc.c.id - ) + q = q.join( + inner_dc, and_(inner_dc.c.id == dce.c.child_collection_id, dce.c.dataset_collection_id == dc.c.id) + ).outerjoin(inner_dce, inner_dce.c.dataset_collection_id == inner_dc.c.id) q = q.add_columns( *attribute_columns(inner_dce.c, element_attributes, nesting_level), *attribute_columns(inner_dc.c, collection_attributes, nesting_level),