Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Add distinct from
Browse files Browse the repository at this point in the history
- Fix no falsy strings
  • Loading branch information
CannonLock committed May 11, 2024
1 parent a8ada79 commit 5c08e00
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/query_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def cast_to_column_type(column: Column, value):
if value == "null":
return None

# If value is a string and the column is a boolean, then cast to boolean
if column.type.python_type == bool:
return value.lower() == "true"

return column.type.python_type(value)
except Exception:
raise ParserException(
Expand Down Expand Up @@ -101,6 +105,14 @@ def _get_operator_expression(column: Column, operators, value: str):
value = cast_to_column_type(column, value)
return column.__ne__(value)

case "is_distinct_from":
value = cast_to_column_type(column, value)
return column.is_distinct_from(value)

case "is_not_distinct_from":
value = cast_to_column_type(column, value)
return column.is_not_distinct_from(value)

case "like":
if value[0] != "%" or value[-1] != "%":
value = f"%{value}%"
Expand Down

0 comments on commit 5c08e00

Please sign in to comment.