diff --git a/manila/db/sqlalchemy/api.py b/manila/db/sqlalchemy/api.py index d18240293b..75f02f686e 100644 --- a/manila/db/sqlalchemy/api.py +++ b/manila/db/sqlalchemy/api.py @@ -42,6 +42,7 @@ from oslo_utils import importutils from oslo_utils import timeutils from oslo_utils import uuidutils import sqlalchemy +from sqlalchemy import and_ from sqlalchemy import MetaData from sqlalchemy import or_ from sqlalchemy.orm import joinedload @@ -2022,8 +2023,8 @@ def _process_share_filters(query, filters, project_id=None, is_public=False): models.ShareTypeExtraSpecs.share_type_id == models.ShareInstance.share_type_id) for k, v in filters['extra_specs'].items(): - query = query.filter(or_(models.ShareTypeExtraSpecs.key == k, - models.ShareTypeExtraSpecs.value == v)) + query = query.filter(and_(models.ShareTypeExtraSpecs.key == k, + models.ShareTypeExtraSpecs.value == v)) return query diff --git a/releasenotes/notes/bug-192912-fix-filtering-shares-by-extra-specs-b79235301306bcf2.yaml b/releasenotes/notes/bug-192912-fix-filtering-shares-by-extra-specs-b79235301306bcf2.yaml new file mode 100644 index 0000000000..cb2579c138 --- /dev/null +++ b/releasenotes/notes/bug-192912-fix-filtering-shares-by-extra-specs-b79235301306bcf2.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Filtering shares by share-type "extra_specs" as + key=value now returns the expected output.