Skip to content

Commit

Permalink
Merge pull request #17817 from mvdbeek/only_join_against_selected_ent…
Browse files Browse the repository at this point in the history
…ities

[24.0] Simplify nested collection joins
  • Loading branch information
martenson authored Mar 24, 2024
2 parents cd96dcc + 234e6bd commit bb0b2ac
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6270,16 +6270,17 @@ def attribute_columns(column_collection, attributes, nesting_level=None):

while ":" in depth_collection_type:
nesting_level += 1
inner_dc = alias(DatasetCollection)
inner_dce = alias(DatasetCollectionElement)
inner_dc = alias(DatasetCollection)
order_by_columns.append(inner_dce.c.element_index)
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),
)
q = q.outerjoin(inner_dce, inner_dce.c.dataset_collection_id == dce.c.child_collection_id)
if collection_attributes:
q = q.join(inner_dc, inner_dc.c.id == dce.c.child_collection_id)
q = q.add_columns(*attribute_columns(inner_dce.c, element_attributes, nesting_level))
if collection_attributes:
q = q.add_columns(
*attribute_columns(inner_dc.c, collection_attributes, nesting_level),
)
dce = inner_dce
dc = inner_dc
depth_collection_type = depth_collection_type.split(":", 1)[1]
Expand Down

0 comments on commit bb0b2ac

Please sign in to comment.