From 14d2d859ef4eb3d21bf6e419a77c2f3185d5cf77 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 15 Jun 2022 10:31:53 +0900 Subject: Set cache_ok to avoid SAWarning Since sqlalchemy 1.4.14[1], the following warning is raised unless the cache_ok flag is explicitly set in classes inheriting TypeDecorator. SAWarning: TypeDecorator Json() 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) Because the flag was set to True by default in older releases, this adds explicit cache_ok = True, to restore the previous behavior in Wallaby and older. (wallaby u-c has SQLAlchemy===1.3.23 while xena u-c has SQLAlchemy===1.4.23) [1] https://github.com/zzzeek/sqlalchemy/commit/6967b4502079e199b12f5eb307d10d27ec92d537 Change-Id: I6b84a626994543468f49373a554de44025576a9a --- heat/db/sqlalchemy/types.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heat/db/sqlalchemy/types.py b/heat/db/sqlalchemy/types.py index 39766b893..4d4a213e5 100644 --- a/heat/db/sqlalchemy/types.py +++ b/heat/db/sqlalchemy/types.py @@ -23,6 +23,7 @@ loads = jsonutils.loads class LongText(types.TypeDecorator): impl = types.Text + cache_ok = True def load_dialect_impl(self, dialect): if dialect.name == 'mysql': @@ -45,6 +46,7 @@ class Json(LongText): class List(types.TypeDecorator): impl = types.Text + cache_ok = True def load_dialect_impl(self, dialect): if dialect.name == 'mysql': -- cgit v1.2.1