Skip to content

Commit

Permalink
Fix some as_sql() signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchainz committed Aug 28, 2022
1 parent 1b596e8 commit 0334564
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/django_mysql/models/lookups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, Callable, Iterable
from typing import Any, Iterable

from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.models import CharField, Lookup, Transform
Expand All @@ -20,11 +20,11 @@ class SoundsLike(Lookup):

def as_sql(
self,
qn: Callable[[str], str],
compiler: SQLCompiler,
connection: BaseDatabaseWrapper,
) -> tuple[str, Iterable[Any]]:
lhs, lhs_params = self.process_lhs(qn, connection)
rhs, rhs_params = self.process_rhs(qn, connection)
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = tuple(lhs_params) + tuple(rhs_params)
return f"{lhs} SOUNDS LIKE {rhs}", params

Expand Down Expand Up @@ -62,10 +62,10 @@ def get_prep_lookup(self) -> Any:
return super().get_prep_lookup()

def as_sql(
self, qn: Callable[[str], str], connection: BaseDatabaseWrapper
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper
) -> tuple[str, Iterable[Any]]:
lhs, lhs_params = self.process_lhs(qn, connection)
rhs, rhs_params = self.process_rhs(qn, connection)
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = tuple(lhs_params) + tuple(rhs_params)
# Put rhs on the left since that's the order FIND_IN_SET uses
return f"FIND_IN_SET({rhs}, {lhs})", params
Expand All @@ -82,9 +82,9 @@ class DynColHasKey(Lookup):
lookup_name = "has_key"

def as_sql(
self, qn: Callable[[str], str], connection: BaseDatabaseWrapper
self, compiler: SQLCompiler, connection: BaseDatabaseWrapper
) -> tuple[str, Iterable[Any]]:
lhs, lhs_params = self.process_lhs(qn, connection)
rhs, rhs_params = self.process_rhs(qn, connection)
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = tuple(lhs_params) + tuple(rhs_params)
return f"COLUMN_EXISTS({lhs}, {rhs})", params

0 comments on commit 0334564

Please sign in to comment.