Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert sanitize_pattern_param in like and ilike #481

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading