feat: add support to NOT LIKE operator (#29384)

This commit is contained in:
Darwin Correa 2024-07-08 13:58:28 -05:00 committed by GitHub
parent ee72d6cdca
commit 9724c99341
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -30,6 +30,7 @@ const BINARY_OPERATORS = [
'<=',
'ILIKE',
'LIKE',
'NOT LIKE',
'REGEX',
'TEMPORAL_RANGE',
] as const;

View File

@ -1909,6 +1909,11 @@ class ExploreMixin: # pylint: disable=too-many-public-methods
where_clause_and.append(sqla_col.like(eq))
else:
where_clause_and.append(sqla_col.ilike(eq))
elif op in {utils.FilterOperator.NOT_LIKE.value}:
if target_generic_type != GenericDataType.STRING:
sqla_col = sa.cast(sqla_col, sa.String)
where_clause_and.append(sqla_col.not_like(eq))
elif (
op == utils.FilterOperator.TEMPORAL_RANGE.value
and isinstance(eq, str)

View File

@ -217,6 +217,7 @@ class FilterOperator(StrEnum):
GREATER_THAN_OR_EQUALS = ">="
LESS_THAN_OR_EQUALS = "<="
LIKE = "LIKE"
NOT_LIKE = "NOT LIKE"
ILIKE = "ILIKE"
IS_NULL = "IS NULL"
IS_NOT_NULL = "IS NOT NULL"