Sqlalchemy column in_() operator does not allow NULL element

Bug #1724177 reported by Lujin Luo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Lujin Luo

Bug Description

I met this issue when I was integrating Floating IP OVO objects. There would be a case that we want to pass router_id=None and fixed_port_id=None into get_objects() method [1], which eventually leads to this method [2].

In my case, since when key is "router_id" and value is "[None]", the in_() clause in Line 205 will not return any matching queries, cause in_() does not support None element.

We need to add a check if [2] when None is contained in value.

[1] https://review.openstack.org/#/c/396351/34..35/neutron/db/l3_db.py@1429
[2] https://github.com/openstack/neutron/blob/master/neutron/db/_model_query.py#L176

Tags: db
Lujin Luo (luo-lujin)
Changed in neutron:
assignee: nobody → Lujin Luo (luo-lujin)
description: updated
Boden R (boden)
Changed in neutron:
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/512908

Changed in neutron:
status: Confirmed → In Progress
Changed in neutron:
importance: Undecided → Medium
tags: added: db
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/512908
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=d104ec67c90a9b0a1eae6f40644424b9df4b4156
Submitter: Zuul
Branch: master

commit d104ec67c90a9b0a1eae6f40644424b9df4b4156
Author: Lujin <email address hidden>
Date: Wed Oct 18 09:56:31 2017 +0900

    Add NULL check before passing to in_() column operator

    In some cases we may need to pass key=None filters to get_object()
    and get_objects() methods, however we lack of NULL check before these
    filters reach in_(), which will not return any matching queries in db
    layer.

    We need to do manual equals matches if NULL element exists in filters,
    instead of pass them to in_() operator.

    Change-Id: I7980b82e2627b7b097cae0a714d22e680cddd340
    Closes-Bug: #1724177

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/516511

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/516511
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=0bbfad2de7fd4b858bd6068a394c8baf5b58cc4a
Submitter: Zuul
Branch: master

commit 0bbfad2de7fd4b858bd6068a394c8baf5b58cc4a
Author: Lujin <email address hidden>
Date: Tue Oct 31 13:30:45 2017 +0900

    Reorder checks in apply_filters in db/_model_query

    Function _kwargs_to_filters() in objects/db/api.py creates a filter
    dictionary where all the values are made iterables except in the case
    of StringMatchingFilterObj objects. As a consequence, when processing
    such a filter, function apply_filters() in db/_model_query.py must
    check if a value is a StringMatchingFilterObj before assuming it is
    an iterable.

    Change-Id: I1b43a06f6e35eaa61c6e6770076a167e6ee83987
    Closes-Bug: #1724177

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 12.0.0.0b2

This issue was fixed in the openstack/neutron 12.0.0.0b2 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.