Merge "Fix comments in _anchors_for_sharing_providers and related test"

This commit is contained in:
Zuul 2018-08-01 13:45:28 +00:00 committed by Gerrit Code Review
commit 392b38b6f9
2 changed files with 7 additions and 4 deletions

View File

@ -457,7 +457,6 @@ def _anchors_for_sharing_providers(context, rp_ids, get_id=False):
# LEFT JOIN resource_providers AS rps
# ON shr_with_sps.root_provider_id = rps.id
# WHERE sps.id IN $(RP_IDs)
# GROUP by shr_with_sps.root_provider_id
rps = sa.alias(_RP_TBL, name='rps')
sps = sa.alias(_RP_TBL, name='sps')
shr_aggs = sa.alias(_RP_AGG_TBL, name='shr_aggs')
@ -472,11 +471,15 @@ def _anchors_for_sharing_providers(context, rp_ids, get_id=False):
join_chain, shr_with_sps,
shr_with_sps_aggs.c.resource_provider_id == shr_with_sps.c.id)
if get_id:
# TODO(yikun): Change `func.coalesce(shr_with_sps.c.root_provider_id,
# shr_with_sps.c.id)` to `shr_with_sps.c.root_provider_id` when we are
# sure all root_provider_id values are NOT NULL
sel = sa.select([sps.c.id, func.coalesce(
shr_with_sps.c.root_provider_id, shr_with_sps.c.id)])
else:
# TODO(efried): Change this to an inner join when we are sure all
# root_provider_id values are NOT NULL
# TODO(efried): Change this to an inner join and change
# 'func.coalesce(rps.c.uuid, shr_with_sps.c.uuid)' to `rps.c.uuid`
# when we are sure all root_provider_id values are NOT NULL
join_chain = sa.outerjoin(
join_chain, rps, shr_with_sps.c.root_provider_id == rps.c.id)
sel = sa.select([sps.c.uuid, func.coalesce(rps.c.uuid,

View File

@ -1041,7 +1041,7 @@ class TestResourceProviderAggregates(tb.PlacementDbBaseTestCase):
# s1 gets s1 (self),
# r1 via agg1 through c1,
# r2 via agg2 AND via agg3 through c2
# r3 via agg2 and agg3
# r3 via agg3
# s5 via agg1 and agg2
expected = set([(s1.uuid, rp.uuid) for rp in (s1, r1, r2, r3, s5)])
self.assertItemsEqual(