Skip to content

Commit

Permalink
fix case with default value for sqlachemy render
Browse files Browse the repository at this point in the history
  • Loading branch information
ea-rus committed Nov 6, 2024
1 parent e01c094 commit 63a206e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mindsdb_sql/render/sqlalchemy_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,11 @@ def prepare_case(self, t: ast.Case):
conditions.append(
(self.to_expression(condition), self.to_expression(result))
)
default = None
if t.default is not None:
conditions.append(self.to_expression(t.default))
default = self.to_expression(t.default)

return sa.case(*conditions)
return sa.case(*conditions, else_=default)

def to_function(self, t):
op = getattr(sa.func, t.op)
Expand Down

0 comments on commit 63a206e

Please sign in to comment.