Skip to content

Commit

Permalink
fix: changed order in _create_last_value_statement for is_active column
Browse files Browse the repository at this point in the history
  • Loading branch information
SteBaum committed Jul 8, 2024
1 parent 7c2481c commit 71d4968
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tdp/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def _create_last_value_statement(column, non_null=False):
"""
order_by = SCHStatusLogModel.event_time.desc()
if non_null:
order_by = case((column == None, 0), else_=1).desc(), order_by
order_by = (
case((column == None, 0), else_=1).desc()
if column is not SCHStatusLogModel.is_active
else case((column == None, 1), else_=0).desc()
), order_by
return func.first_value(column).over(
partition_by=(
SCHStatusLogModel.service,
Expand Down

0 comments on commit 71d4968

Please sign in to comment.