From 10e8e77a92455fb638dcc7e73c044cd22acd84ad Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 8 Sep 2022 10:45:05 +0100 Subject: types: Set 'cache_ok' (redux) In change Idf6fd858fad9521c7c5ba82c31b6d3077756abd9, we defined the 'cache_ok' key on a number of custom types. However, we relied on this attribute being inheritable which is not the case due to how that attribute is checked for [1]. As a result, we must set this attribute on every one of our custom types. [1] https://github.com/sqlalchemy/sqlalchemy/blob/rel_1_4_41/lib/sqlalchemy/sql/type_api.py#L984 Change-Id: I005af8c7afe3b5104068ca153aecbfe54e163ca3 Signed-off-by: Stephen Finucane --- oslo_db/sqlalchemy/types.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/oslo_db/sqlalchemy/types.py b/oslo_db/sqlalchemy/types.py index a86f5ac..fe40bbd 100644 --- a/oslo_db/sqlalchemy/types.py +++ b/oslo_db/sqlalchemy/types.py @@ -69,6 +69,8 @@ class JsonEncodedDict(JsonEncodedType): """ type = dict + cache_ok = True + """This type is safe to cache.""" class JsonEncodedList(JsonEncodedType): @@ -81,6 +83,8 @@ class JsonEncodedList(JsonEncodedType): """ type = list + cache_ok = True + """This type is safe to cache.""" class SoftDeleteInteger(TypeDecorator): @@ -120,9 +124,11 @@ class String(_String): mysql_ndb_type is used to override the String with another data type. mysql_ndb_size is used to adjust the length of the String. - """ + cache_ok = True + """This type is safe to cache.""" + def __init__( self, length, mysql_ndb_length=None, mysql_ndb_type=None, **kw): """Initialize options.""" -- cgit v1.2.1