Skip to content

Commit

Permalink
Save original result columns
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Nov 1, 2023
1 parent 71f7ae7 commit 8c88538
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6171,12 +6171,15 @@ def attribute_columns(column_collection, attributes, nesting_level=None):
if entity == DatasetCollectionElement:
q = q.filter(entity.id == dce.c.id)

# Since we will apply DISTINCT, ensure all columns from the ORDER BY clause are explicitly selected
# Since we apply DISTINCT, ensure all columns from the ORDER BY clause are explicitly selected.
# We also need to make sure these added columns are not added to the result: this method returns lists of models
# or lists of tuples of values. With the latter the additional columns won't cause a problem, but lists of models
# will become lists of tuples of models + additional columns, which will break downstream logic.
q_columns = q._raw_columns
for col in order_by_columns:
if col not in q.statement._raw_columns: # do not select a column more than once.
q = q.add_column(col)

return q.distinct().order_by(*order_by_columns)
return q.distinct().order_by(*order_by_columns).with_entities(*q_columns)

@property
def dataset_states_and_extensions_summary(self):
Expand Down

0 comments on commit 8c88538

Please sign in to comment.