From 02e37edf0e0d0ab175048aff20bfd6b28c36da76 Mon Sep 17 00:00:00 2001 From: Toggle <89287578+tgle@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:53:33 +1000 Subject: [PATCH] Set cache_ok=True for CIText type Fixes #25, an SAWarning when performing queries with CIText columns --- citext/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/citext/__init__.py b/citext/__init__.py index b9c4bd9..e048217 100644 --- a/citext/__init__.py +++ b/citext/__init__.py @@ -10,6 +10,10 @@ class CIText(types.Concatenable, types.UserDefinedType): + # Tell SQLAlchemy that CIText strings are safe to use as cache keys (like regular strings) + # https://docs.sqlalchemy.org/en/14/core/custom_types.html#sqlalchemy.types.TypeDecorator.cache_ok + cache_ok = True + # This is copied from the `literal_processor` of sqlalchemy's own `String` # type. def literal_processor(self, dialect):