]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Fix incorrect query for user ip allocations
authorEugene Nikanorov <enikanorov@mirantis.com>
Sat, 18 Apr 2015 11:31:44 +0000 (15:31 +0400)
committerEugene Nikanorov <enikanorov@mirantis.com>
Wed, 22 Apr 2015 11:35:45 +0000 (15:35 +0400)
commit0109578a8ec07f743f7e2b654007e17f145ea20f
tree895c758cc2c3c7dae8f1ba39093b651cce006377
parent76d873a452e340944e2e3242e8bb1722e3c036e8
Fix incorrect query for user ip allocations

Previously the query was fetching an IPAllocation object incorrectly
relying on the fact that it has port attribute that should be
join-loaded when it really is not.

Incorrect query produced by previous code:
SELECT ipallocations.port_id AS ipallocations_port_id,
       ipallocations.ip_address AS ipallocations_ip_address,
       ipallocations.subnet_id AS ipallocations_subnet_id,
       ipallocations.network_id AS ipallocations_network_id
FROM ipallocations, ports
WHERE ipallocations.subnet_id = :subnet_id_1
      AND ports.device_owner NOT IN (:device_owner_1)

The query then may have produced results that don't satisfy
the condition intended by the code.

Query produced by the fixed code:
SELECT ipallocations.port_id AS ipallocations_port_id,
       ipallocations.ip_address AS ipallocations_ip_address,
       ipallocations.subnet_id AS ipallocations_subnet_id,
       ipallocations.network_id AS ipallocations_network_id
FROM ipallocations JOIN ports ON ports.id = ipallocations.port_id
WHERE ipallocations.subnet_id = :subnet_id_1
      AND ports.device_owner NOT IN (:device_owner_1)

Change-Id: I34682df784e30e3ce49ee48c690f8b799ad58149
Closes-Bug: #1357055
neutron/db/db_base_plugin_v2.py
neutron/tests/unit/db/test_db_base_plugin_v2.py