Skip to content

Commit

Permalink
Use is_ and is_not for null comparisons in filters
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Apr 24, 2023
1 parent 753789d commit 1b64587
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/prefect/server/schemas/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ def _get_filter_list(self, db: "PrefectDBInterface") -> List:
filters.append(db.FlowRun.deployment_id.in_(self.any_))
if self.is_null_ is not None:
filters.append(
db.FlowRun.deployment_id is None
db.FlowRun.deployment_id.is_(None)
if self.is_null_
else db.FlowRun.deployment_id is not None
else db.FlowRun.deployment_id.is_not(None)
)
return filters

Expand All @@ -278,9 +278,9 @@ def _get_filter_list(self, db: "PrefectDBInterface") -> List:
filters.append(db.FlowRun.work_queue_name.in_(self.any_))
if self.is_null_ is not None:
filters.append(
db.FlowRun.work_queue_name is None
db.FlowRun.work_queue_name.is_(None)
if self.is_null_
else db.FlowRun.work_queue_name is not None
else db.FlowRun.work_queue_name.is_not(None)
)
return filters

Expand Down Expand Up @@ -361,9 +361,9 @@ def _get_filter_list(self, db: "PrefectDBInterface") -> List:
filters.append(db.FlowRun.start_time >= self.after_)
if self.is_null_ is not None:
filters.append(
db.FlowRun.start_time is None
db.FlowRun.start_time.is_(None)
if self.is_null_
else db.FlowRun.start_time is not None
else db.FlowRun.start_time.is_not(None)
)
return filters

Expand Down Expand Up @@ -433,9 +433,9 @@ def _get_filter_list(self, db: "PrefectDBInterface") -> List:
filters.append(db.FlowRun.parent_task_run_id.in_(self.any_))
if self.is_null_ is not None:
filters.append(
db.FlowRun.parent_task_run_id is None
db.FlowRun.parent_task_run_id.is_(None)
if self.is_null_
else db.FlowRun.parent_task_run_id is not None
else db.FlowRun.parent_task_run_id.is_not(None)
)
return filters

Expand Down Expand Up @@ -683,9 +683,9 @@ def _get_filter_list(self, db: "PrefectDBInterface") -> List:
filters.append(db.TaskRun.start_time >= self.after_)
if self.is_null_ is not None:
filters.append(
db.TaskRun.start_time is None
db.TaskRun.start_time.is_(None)
if self.is_null_
else db.TaskRun.start_time is not None
else db.TaskRun.start_time.is_not(None)
)
return filters

Expand Down

0 comments on commit 1b64587

Please sign in to comment.