From c35b101b9e6211a9806897ce11d8dd246bab0983 Mon Sep 17 00:00:00 2001 From: Armando Migliaccio Date: Mon, 31 Jul 2017 17:35:27 -0700 Subject: [PATCH] Switch to using bool for filtering non-deleted volume attributes This avoid programmatic errors when talking to a DB backend like Postgres due to integer/bool type mismatch. This patch also addresses model/schema mismatches where column 'deleted' was defined as Integer, but created as Boolean. Closes-bug: #1707989 Change-Id: I1f6da598b5bb45f7ce3deb1416eeec9ceb486f02 --- cinder/db/sqlalchemy/api.py | 2 +- cinder/db/sqlalchemy/models.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 48761dc7635..275478bfff2 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -3473,7 +3473,7 @@ def _process_group_types_filters(query, filters): if filters['is_public'] and context.project_id is not None: projects_attr = getattr(models.GroupTypes, 'projects') the_filter.extend([ - projects_attr.any(project_id=context.project_id, deleted=0) + projects_attr.any(project_id=context.project_id, deleted=False) ]) if len(the_filter) > 1: query = query.filter(or_(*the_filter)) diff --git a/cinder/db/sqlalchemy/models.py b/cinder/db/sqlalchemy/models.py index 569b821580e..66752dc6318 100644 --- a/cinder/db/sqlalchemy/models.py +++ b/cinder/db/sqlalchemy/models.py @@ -446,7 +446,6 @@ class GroupTypeProjects(BASE, CinderBase): group_type_id = Column(String, ForeignKey('group_types.id'), nullable=False) project_id = Column(String(255)) - deleted = Column(Integer, default=0) group_type = relationship( GroupTypes, @@ -454,7 +453,7 @@ class GroupTypeProjects(BASE, CinderBase): foreign_keys=group_type_id, primaryjoin='and_(' 'GroupTypeProjects.group_type_id == GroupTypes.id,' - 'GroupTypeProjects.deleted == 0)') + 'GroupTypeProjects.deleted == False)') class VolumeTypeExtraSpecs(BASE, CinderBase):