Skip to content

Commit

Permalink
Fix bug (replace str with model attrs in join clauses), fix SA2.0 req…
Browse files Browse the repository at this point in the history
…uirements

SA2.0: add unique() to joinedload result
  • Loading branch information
jdavcs committed Sep 26, 2023
1 parent 89f1763 commit e0b6b3b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/galaxy/model/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
HistoryDatasetAssociationDisplayAtAuthorization,
Library,
LibraryDataset,
LibraryDatasetDatasetAssociation,
LibraryDatasetPermissions,
LibraryPermissions,
Role,
Expand Down Expand Up @@ -1535,17 +1536,14 @@ def check_folder_contents(self, user, roles, folder, hidden_folder_ids=""):
return True, ""
action = self.permitted_actions.DATASET_ACCESS

lddas = (
self.sa_session.query(self.model.LibraryDatasetDatasetAssociation)
.join("library_dataset")
.filter(self.model.LibraryDataset.folder == folder)
.join("dataset")
.options(
joinedload(self.model.LibraryDatasetDatasetAssociation.dataset).joinedload(self.model.Dataset.actions)
)
.all()
stmt = (
select(LibraryDatasetDatasetAssociation)
.join(LibraryDatasetDatasetAssociation.library_dataset)
.where(LibraryDataset.folder == folder)
.join(Dataset)
.options(joinedload(LibraryDatasetDatasetAssociation.dataset).joinedload(Dataset.actions))
)

lddas = self.sa_session.scalars(stmt).unique()
for ldda in lddas:
ldda_access_permissions = self.get_item_actions(action, ldda.dataset)
if not ldda_access_permissions:
Expand Down

0 comments on commit e0b6b3b

Please sign in to comment.