diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 9e7a55a9fe16..43be96ae01e2 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -6146,9 +6146,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),