From 38b11075741f7a4581fc7bea6f9bbc00ced87274 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Mon, 29 Jan 2024 12:43:27 -0600 Subject: [PATCH] [23.0] Fix History contents `genome_build` filter postgresql bug Check the user's db connection and use appropriate query/function. --- lib/galaxy/managers/genomes.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/managers/genomes.py b/lib/galaxy/managers/genomes.py index f6af2d73d9a7..ce67796d34ad 100644 --- a/lib/galaxy/managers/genomes.py +++ b/lib/galaxy/managers/genomes.py @@ -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 ( @@ -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