Skip to content

Commit

Permalink
fix: revert sanitize_pattern_param in like and ilike (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks authored Aug 8, 2024
1 parent c4fb13b commit 18ed416
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 37 deletions.
10 changes: 1 addition & 9 deletions postgrest/base_request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@
from pydantic import validator as field_validator

from .types import CountMethod, Filters, RequestMethod, ReturnMethod
from .utils import (
AsyncClient,
SyncClient,
get_origin_and_cast,
sanitize_param,
sanitize_pattern_param,
)
from .utils import AsyncClient, SyncClient, get_origin_and_cast, sanitize_param


class QueryArgs(NamedTuple):
Expand Down Expand Up @@ -347,7 +341,6 @@ def like(self: Self, column: str, pattern: str) -> Self:
column: The name of the column to apply a filter on
pattern: The pattern to filter by
"""
pattern = sanitize_pattern_param(pattern)
return self.filter(column, Filters.LIKE, pattern)

def like_all_of(self: Self, column: str, pattern: str) -> Self:
Expand Down Expand Up @@ -397,7 +390,6 @@ def ilike(self: Self, column: str, pattern: str) -> Self:
column: The name of the column to apply a filter on
pattern: The pattern to filter by
"""
pattern = sanitize_pattern_param(pattern)
return self.filter(column, Filters.ILIKE, pattern)

def or_(self: Self, filters: str, reference_table: Union[str, None] = None) -> Self:
Expand Down
16 changes: 2 additions & 14 deletions tests/_async/test_filter_request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,25 +190,13 @@ def test_overlaps_with_timestamp_range(filter_request_builder):
def test_like(filter_request_builder):
builder = filter_request_builder.like("x", "%a%")

assert str(builder.params) == "x=like.%2Aa%2A"


def test_like2(filter_request_builder):
builder = filter_request_builder.like("x", f"%{85770204020}%") # See bug #830.

assert str(builder.params) == "x=like.%2A85770204020%2A"
assert str(builder.params) == "x=like.%a%"


def test_ilike(filter_request_builder):
builder = filter_request_builder.ilike("x", "%a%")

assert str(builder.params) == "x=ilike.%2Aa%2A"


def test_ilike2(filter_request_builder):
builder = filter_request_builder.ilike("x", f"%{85770204020}%") # See bug #830.

assert str(builder.params) == "x=ilike.%2A85770204020%2A"
assert str(builder.params) == "x=ilike.%a%"


def test_like_all_of(filter_request_builder):
Expand Down
16 changes: 2 additions & 14 deletions tests/_sync/test_filter_request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,25 +190,13 @@ def test_overlaps_with_timestamp_range(filter_request_builder):
def test_like(filter_request_builder):
builder = filter_request_builder.like("x", "%a%")

assert str(builder.params) == "x=like.%2Aa%2A"


def test_like2(filter_request_builder):
builder = filter_request_builder.like("x", f"%{85770204020}%") # See bug #830.

assert str(builder.params) == "x=like.%2A85770204020%2A"
assert str(builder.params) == "x=like.%a%"


def test_ilike(filter_request_builder):
builder = filter_request_builder.ilike("x", "%a%")

assert str(builder.params) == "x=ilike.%2Aa%2A"


def test_ilike2(filter_request_builder):
builder = filter_request_builder.ilike("x", f"%{85770204020}%") # See bug #830.

assert str(builder.params) == "x=ilike.%2A85770204020%2A"
assert str(builder.params) == "x=ilike.%a%"


def test_like_all_of(filter_request_builder):
Expand Down

0 comments on commit 18ed416

Please sign in to comment.