Skip to content

Commit

Permalink
[23.0] Fix History contents genome_build filter postgresql bug
Browse files Browse the repository at this point in the history
Check the user's db connection and use appropriate query/function.
  • Loading branch information
ahmedhamidawan committed Jan 29, 2024
1 parent f9be1a4 commit 38b1107
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/galaxy/managers/genomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
TYPE_CHECKING,
)

from sqlalchemy import func
from sqlalchemy import (
func,
text,
)

from galaxy import model as m
from galaxy.exceptions import (
Expand Down Expand Up @@ -86,7 +89,11 @@ def _create_genome_filter(model_class=None):
# Doesn't filter genome_build for collections
if model_class.__name__ == "HistoryDatasetCollectionAssociation":
return False
column = func.json_extract(model_class.table.c._metadata, "$.dbkey")
# TODO: should use is_postgres(self.app.config.database_connection) in 23.2
if self.app.config.database_connection.startswith("postgres"):
column = text("convert_from(metadata, 'UTF8')::json ->> 'dbkey'")
else:
column = func.json_extract(model_class.table.c._metadata, "$.dbkey")
lower_val = val.lower() # Ignore case
if op == "eq":
cond = func.lower(column) == lower_val
Expand Down

0 comments on commit 38b1107

Please sign in to comment.