From 4298b66fd86758de4fb2177c8a7f98cb9b625d85 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 10 Nov 2024 23:01:40 +0300 Subject: [PATCH] fix case render --- mindsdb_sql/render/sqlalchemy_render.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mindsdb_sql/render/sqlalchemy_render.py b/mindsdb_sql/render/sqlalchemy_render.py index 7a30aea..929f262 100644 --- a/mindsdb_sql/render/sqlalchemy_render.py +++ b/mindsdb_sql/render/sqlalchemy_render.py @@ -297,7 +297,11 @@ def prepare_case(self, t: ast.Case): if t.default is not None: default = self.to_expression(t.default) - return sa.case(*conditions, else_=default) + value = None + if t.arg is not None: + value = self.to_expression(t.arg) + + return sa.case(*conditions, else_=default, value=value) def to_function(self, t): op = getattr(sa.func, t.op)