Configure 'cache_ok' for TypeDecorator implementation
Both the JSONEncodedDict and TimestampUTC can be safely used in a cache key. Set 'cache_ok' to indicate this. This resolves the following warnings: SAWarning: TypeDecorator TimestampUTC() will not produce a cache key because the ``cache_ok`` attribute is not set to True. This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions. Set this attribute to True if this type object's state is safe to use in a cache key, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf) SAWarning: TypeDecorator JSONEncodedDict() will not produce a cache key because the ``cache_ok`` attribute is not set to True. This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions. Set this attribute to True if this type object's state is safe to use in a cache ke y, or False to disable this warning. (Background on this error at: https://sqlalche.me/e/14/cprf) Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Change-Id: I589a0e378e155dcb181e6b1a9cca7aae4cad5349
This commit is contained in:
parent
3bd47b2b50
commit
90076472ac
@ -28,6 +28,7 @@ class JSONEncodedDict(TypeDecorator):
|
||||
"""Represents an immutable structure as a json-encoded string."""
|
||||
|
||||
impl = Text
|
||||
cache_ok = True
|
||||
|
||||
@staticmethod
|
||||
def process_bind_param(value, dialect):
|
||||
@ -46,6 +47,7 @@ class TimestampUTC(TypeDecorator):
|
||||
"""Represents a timestamp precise to the microsecond."""
|
||||
|
||||
impl = DateTime
|
||||
cache_ok = True
|
||||
|
||||
def load_dialect_impl(self, dialect):
|
||||
if dialect.name == 'mysql':
|
||||
|
Loading…
x
Reference in New Issue
Block a user