Fix a usage error of joinedload + filter in dhcp scheduler
This commit fixes filtering in get_dhcp_agents_hosting_networks.
Also, separate the argument "active" into two; active (heartbeat thing)
and admin_state_up. Because all in-tree callers with active=True seem
to mean only the former, currently the new admin_state_up argument is not
used. (Thus this commit doesn't change any behaviour yet. The argument
might be useful for other changes like [1])
With the current coding, joinedload() produces a JOIN and
the following filter() on the columns from the joined table
would create another JOIN of the same table. (As t1 in the
following example). It doesn't seem to be the intended
behaviour. As a consequence the filter (WHERE clause in
the following examples) doesn't work as expected.
Queries before this fix looked like the following,
where t1 and t2 are Agent and NetworkDhcpAgentBinding respectively:
SELECT t2.aaa, t1_1.bbb, ...
FROM t1, t2 LEFT OUTER JOIN t1 AS t1_1 ON t1_1.ccc = t2.ddd
WHERE t1.eee = ...;
After the fix, it would be:
SELECT t2.aaa, t1.bbb, ...
FROM t2 JOIN t1 ON t1.ccc = t2.ddd
WHERE t1.eee = ...;
Reviewed: https:/ /review. openstack. org/150284 /git.openstack. org/cgit/ openstack/ neutron/ commit/ ?id=96aa9f93600 d6e97394ad725e0 95d5539848ca2d
Committed: https:/
Submitter: Jenkins
Branch: master
commit 96aa9f93600d6e9 7394ad725e095d5 539848ca2d
Author: YAMAMOTO Takashi <email address hidden>
Date: Tue Jan 27 15:33:36 2015 +0900
Fix a usage error of joinedload + filter in dhcp scheduler
This commit fixes filtering in get_dhcp_ agents_ hosting_ networks.
Also, separate the argument "active" into two; active (heartbeat thing)
and admin_state_up. Because all in-tree callers with active=True seem
to mean only the former, currently the new admin_state_up argument is not
used. (Thus this commit doesn't change any behaviour yet. The argument
might be useful for other changes like [1])
[1] https:/ /review. openstack. org/#/c/ 147032/
Details:
With the current coding, joinedload() produces a JOIN and
the following filter() on the columns from the joined table
would create another JOIN of the same table. (As t1 in the
following example). It doesn't seem to be the intended
behaviour. As a consequence the filter (WHERE clause in
the following examples) doesn't work as expected.
Queries before this fix looked like the following, tBinding respectively:
where t1 and t2 are Agent and NetworkDhcpAgen
SELECT t2.aaa, t1_1.bbb, ...
FROM t1, t2 LEFT OUTER JOIN t1 AS t1_1 ON t1_1.ccc = t2.ddd
WHERE t1.eee = ...;
After the fix, it would be:
SELECT t2.aaa, t1.bbb, ...
FROM t2 JOIN t1 ON t1.ccc = t2.ddd
WHERE t1.eee = ...;
Reference: http:// docs.sqlalchemy .org/en/ rel_0_9/ orm/loading_ relationships. html#contains- eager
Closes-Bug: #1414905 fba8c18c357ffa1 0cf0f398140
Change-Id: Idf9ffdb849de58