diff options
author | Rodolfo Alonso Hernandez <ralonsoh@redhat.com> | 2021-06-04 16:22:17 +0000 |
---|---|---|
committer | Rodolfo Alonso <ralonsoh@redhat.com> | 2021-06-07 13:23:44 +0000 |
commit | 2f8625efbdd5ceba2c5d7b5444a8e263547a1f9f (patch) | |
tree | 4e6f567494a949d23bf89a03ac2c5ad028eab538 | |
parent | 63ef8f81f34a41d9e242e44658c962dc86186d80 (diff) | |
download | keystone-2f8625efbdd5ceba2c5d7b5444a8e263547a1f9f.tar.gz |
Make DB queries compatible with SQLAlchemy 1.4.x
Change-Id: I25eae9e6de8534b40493caf23cc49602a44efd26
Closes-Bug: #1930908
-rw-r--r-- | keystone/common/sql/core.py | 8 | ||||
-rw-r--r-- | keystone/identity/shadow_backends/sql.py | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/keystone/common/sql/core.py b/keystone/common/sql/core.py index ed84e5893..89169aaf3 100644 --- a/keystone/common/sql/core.py +++ b/keystone/common/sql/core.py @@ -119,6 +119,10 @@ ModelBase.__init__ = initialize_decorator(ModelBase.__init__) class JsonBlob(sql_types.TypeDecorator): impl = sql.Text + # NOTE(ralonsoh): set to True as any other TypeDecorator in SQLAlchemy + # https://docs.sqlalchemy.org/en/14/core/custom_types.html# \ + # sqlalchemy.types.TypeDecorator.cache_ok + cache_ok = True def process_bind_param(self, value, dialect): return jsonutils.dumps(value) @@ -144,6 +148,10 @@ class DateTimeInt(sql_types.TypeDecorator): impl = sql.BigInteger epoch = datetime.datetime.fromtimestamp(0, tz=pytz.UTC) + # NOTE(ralonsoh): set to True as any other TypeDecorator in SQLAlchemy + # https://docs.sqlalchemy.org/en/14/core/custom_types.html# \ + # sqlalchemy.types.TypeDecorator.cache_ok + cache_ok = True def process_bind_param(self, value, dialect): if value is None: diff --git a/keystone/identity/shadow_backends/sql.py b/keystone/identity/shadow_backends/sql.py index 1d817c038..3e04b332d 100644 --- a/keystone/identity/shadow_backends/sql.py +++ b/keystone/identity/shadow_backends/sql.py @@ -98,7 +98,8 @@ class ShadowUsers(base.ShadowUsersDriverBase): x for x in hints.filters if x['name'] not in ('idp_id', 'protocol_id', 'unique_id')] - query = query.filter(sqlalchemy.and_(*statements)) + if statements: + query = query.filter(sqlalchemy.and_(*statements)) return query def get_federated_users(self, hints): |