Filter subnet by segment ID or None

In "_query_filter_by_fixed_ips_segment", the subnet query should be
filtered by segment ID if exists, or None otherwise.

The "segment_id" field (from the "subnet" DB register) is a string.
As reported in the related bug, PostgreSQL does not accept to compare
this field with a boolean value ("false"). This patch avoids the
previous situation where the DB WHERE statement was trying to compare
a string and a boolean:

  operator does not exist: character varying = boolean
  LINE 5: WHERE anon_1.subnets_segment_id = false
  No operator matches the given name and argument type(s). You might \
    need to add explicit type casts.

Change-Id: I1ff29eb45c6663885c2b8a126a3669e75b920c98
Closes-Bug: #1869034
This commit is contained in:
Rodolfo Alonso Hernandez 2020-03-25 17:35:15 +00:00
parent 890392a388
commit 79e8230e39
1 changed files with 1 additions and 2 deletions

View File

@ -393,8 +393,7 @@ class Subnet(base.NeutronDbObject):
if 1 < len(segment_ids):
raise segment_exc.FixedIpsSubnetsNotOnSameSegment()
segment_id = False if not segment_ids else segment_ids[0]
segment_id = None if not segment_ids else segment_ids[0]
return query.filter(cls.db_model.segment_id == segment_id)
@classmethod