Source code for core.orm.types.lowercase_text_type

from sqlalchemy.types import TypeDecorator, TEXT
from sqlalchemy_utils.operators import CaseInsensitiveComparator


from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from sqlalchemy.engine.interfaces import Dialect
[docs] _Base = TypeDecorator[str]
else: _Base = TypeDecorator
[docs] class LowercaseText(_Base): """ Text column that forces all text to be lowercase. """
[docs] impl = TEXT
# FIXME: This was spelled incorrectly, but fixing the spelling # causes some issues with custom join conditions
[docs] omparator_factory = CaseInsensitiveComparator
[docs] def process_bind_param( self, value: str | None, dialect: 'Dialect' ) -> str | None: return None if value is None else value.lower()