diff options
author | Stephen Finucane <stephenfin@redhat.com> | 2021-06-22 11:54:01 +0100 |
---|---|---|
committer | Stephen Finucane <stephenfin@redhat.com> | 2021-06-22 18:10:46 +0100 |
commit | 1dc20f646b558354e4ba434f4132a1b7979d563e (patch) | |
tree | 0d7af83f71eb4a348cca3355cc4835d212993b7d | |
parent | be2cc6a2ce40f6666d1e2b0f13054e7be7bc792e (diff) | |
download | oslo-db-1dc20f646b558354e4ba434f4132a1b7979d563e.tar.gz |
types: Set 'cache_ok'
Resolves the following warning that has been popping up on tests:
SAWarning: TypeDecorator SoftDeleteInteger() will not produce a cache
key because the ``cache_ok`` flag is not set to True. Set this flag
to True if this type object's state is safe to use in a cache key, or
False to disable this warning.
Both SoftDeleteInteger and the various subclasses of 'JsonEncodedType'
are hashable and should return a consistent hash and key. For more
information, refer to the SQLAlchemy docs [1].
[1] https://docs.sqlalchemy.org/en/14/core/custom_types.html#sqlalchemy.types.TypeDecorator.cache_ok
Change-Id: Idf6fd858fad9521c7c5ba82c31b6d3077756abd9
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
-rw-r--r-- | oslo_db/sqlalchemy/types.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/oslo_db/sqlalchemy/types.py b/oslo_db/sqlalchemy/types.py index 08b1f2b..d4d9069 100644 --- a/oslo_db/sqlalchemy/types.py +++ b/oslo_db/sqlalchemy/types.py @@ -21,6 +21,8 @@ class JsonEncodedType(TypeDecorator): type = None impl = Text + cache_ok = True + """This type is safe to cache.""" def __init__(self, mysql_as_long=False, mysql_as_medium=False): """Initialize JSON-encoding type.""" @@ -101,6 +103,8 @@ class SoftDeleteInteger(TypeDecorator): """ impl = Integer + cache_ok = True + """This type is safe to cache.""" def process_bind_param(self, value, dialect): """Return the binding parameter.""" |