diff --git a/manila/db/sqlalchemy/api.py b/manila/db/sqlalchemy/api.py index ec4470e955..611bdcefa4 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 @@ -2016,8 +2017,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.