#from django.db.models import Lookup
from django.db.models.lookups import IContains
from django.db.models.fields import Field


@Field.register_lookup
class Ilike(IContains):
    lookup_name = "ilike"

    def as_sql(self, compiler, connection):
        lhs, lhs_params = self.process_lhs(compiler, connection)
        rhs, rhs_params = self.process_rhs(compiler, connection)
        params = lhs_params + rhs_params
        return f"{lhs} ILIKE {rhs}", params
