[sqlalchemy-20] Do not use strings for aatribute names in loader options
The method ``get_l3_agents_by_router_ids`` is retrieving the ``RouterL3AgentBinding`` registers along with the ``Agent`` information. This left outer join should be explictly defined using the database model. Expected query: SELECT routerl3agentbindings.router_id AS ... FROM routerl3agentbindings LEFT OUTER JOIN agents ON agents.id = routerl3agentbindings.l3_agent_id WHERE routerl3agentbindings.router_id IN (XXX) Closes-Bug: #2012662 Change-Id: Ife9ba5d774934d2cd1a86b3281b78e854d88de3c
This commit is contained in:
committed by
Rodolfo Alonso
parent
0a69dd5e3d
commit
e4da60740b
@@ -13,7 +13,6 @@
|
||||
from neutron_lib.db import api as db_api
|
||||
from neutron_lib.objects import common_types
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from sqlalchemy import sql
|
||||
|
||||
@@ -46,7 +45,8 @@ class RouterL3AgentBinding(base.NeutronDbObject):
|
||||
@db_api.CONTEXT_READER
|
||||
def get_l3_agents_by_router_ids(cls, context, router_ids):
|
||||
query = context.session.query(l3agent.RouterL3AgentBinding)
|
||||
query = query.options(joinedload('l3_agent')).filter(
|
||||
query = query.outerjoin(agent_model.Agent)
|
||||
query = query.filter(
|
||||
l3agent.RouterL3AgentBinding.router_id.in_(router_ids))
|
||||
return [db_obj.l3_agent for db_obj in query.all()]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user