Merge "[PostgreSQL] Subnet entity with ServiceType grouped by both tables"

This commit is contained in:
Zuul 2023-07-20 16:04:18 +00:00 committed by Gerrit Code Review
commit dc1b7851af
1 changed files with 8 additions and 0 deletions

View File

@ -183,6 +183,14 @@ class SubnetServiceType(base.NeutronDbObject):
and_(Subnet.enable_dhcp.is_(True),
service_type == const.DEVICE_OWNER_DHCP)))
if query._group_by_clauses:
# If the "Subnet" query has a "GROUP BY" clause (that happens when
# a non-admin user has executed the query, that requires the join
# of the RBAC registers), it is needed to add the
# "SubnetServiceType" fields to this clause too.
query = query.group_by(ServiceType.subnet_id,
ServiceType.service_type)
entity = orm.aliased(Subnet, query.subquery())
return entity