From 911d72c95783966e7503ac6fd7bcdd64c8400a84 Mon Sep 17 00:00:00 2001 From: Amin Ghadersohi Date: Mon, 12 Jan 2026 11:53:04 -0500 Subject: [PATCH] fix(models): prevent SQLAlchemy and_() deprecation warning (#37020) Co-authored-by: Claude Opus 4.5 --- superset/models/helpers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/superset/models/helpers.py b/superset/models/helpers.py index c180420a91c..9be9efb43d1 100644 --- a/superset/models/helpers.py +++ b/superset/models/helpers.py @@ -3214,10 +3214,12 @@ class ExploreMixin: # pylint: disable=too-many-public-methods ) if granularity: - qry = qry.where(and_(*(time_filters + where_clause_and))) - else: + if time_filters or where_clause_and: + qry = qry.where(and_(*(time_filters + where_clause_and))) + elif where_clause_and: qry = qry.where(and_(*where_clause_and)) - qry = qry.having(and_(*having_clause_and)) + if having_clause_and: + qry = qry.having(and_(*having_clause_and)) self.make_orderby_compatible(select_exprs, orderby_exprs)