summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/traversals.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-05-06 12:24:00 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-05-06 13:57:43 -0400
commit6967b4502079e199b12f5eb307d10d27ec92d537 (patch)
tree01ac7d137bee27bfd8ec9432639115327e1fe636 /lib/sqlalchemy/sql/traversals.py
parent900d76b8f757a8a42bfb8fc737d24a94eeeac05f (diff)
downloadsqlalchemy-6967b4502079e199b12f5eb307d10d27ec92d537.tar.gz
don't cache TypeDecorator by default
The :class:`.TypeDecorator` class will now emit a warning when used in SQL compilation with caching unless the ``.cache_ok`` flag is set to ``True`` or ``False``. ``.cache_ok`` indicates that all the parameters passed to the object are safe to be used as a cache key, ``False`` means they are not. Fixes: #6436 Change-Id: Ib1bb7dc4b124e38521d615c2e2e691e4915594fb
Diffstat (limited to 'lib/sqlalchemy/sql/traversals.py')
-rw-r--r--lib/sqlalchemy/sql/traversals.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/traversals.py b/lib/sqlalchemy/sql/traversals.py
index f2099f191..e8a805285 100644
--- a/lib/sqlalchemy/sql/traversals.py
+++ b/lib/sqlalchemy/sql/traversals.py
@@ -152,7 +152,11 @@ class HasCacheKey(object):
# efficient switch construct
if meth is STATIC_CACHE_KEY:
- result += (attrname, obj._static_cache_key)
+ sck = obj._static_cache_key
+ if sck is NO_CACHE:
+ anon_map[NO_CACHE] = True
+ return None
+ result += (attrname, sck)
elif meth is ANON_NAME:
elements = util.preloaded.sql_elements
if isinstance(obj, elements._anonymous_label):