summaryrefslogtreecommitdiff
path: root/neutron
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-04-28 21:25:03 +0000
committerGerrit Code Review <review@openstack.org>2021-04-28 21:25:03 +0000
commit30935109262b1fe401b38ee9bcb4e9dc9a3bed13 (patch)
treec2d5df7ae840973eca9a905977a01427316e7955 /neutron
parent57f34438c9b553c9598d82c7032fff0273ad227c (diff)
parentde295f036df2cedec9de4c25f344ebb770f66e0a (diff)
downloadneutron-30935109262b1fe401b38ee9bcb4e9dc9a3bed13.tar.gz
Merge "Do not include dynamically loaded values into OVO testing"
Diffstat (limited to 'neutron')
-rw-r--r--neutron/objects/base.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/neutron/objects/base.py b/neutron/objects/base.py
index 41a24ee56b..614082711e 100644
--- a/neutron/objects/base.py
+++ b/neutron/objects/base.py
@@ -30,6 +30,7 @@ from oslo_versionedobjects import base as obj_base
from oslo_versionedobjects import exception as obj_exception
from oslo_versionedobjects import fields as obj_fields
from sqlalchemy import orm
+from sqlalchemy.orm import query as sqla_query
from neutron._i18n import _
from neutron.db import standard_attr
@@ -518,8 +519,14 @@ class NeutronDbObject(NeutronObject, metaclass=DeclarativeObject):
# db.keys() so we must fetch data based on object fields definition
potential_fields = (list(cls.fields.keys()) +
list(cls.fields_need_translation.values()))
- result = {field: db_obj[field] for field in potential_fields
- if db_obj.get(field) is not None}
+ # NOTE(ralonsoh): fields dynamically loaded will be represented as
+ # ``sqla_query.Query``, because the value is load when needed executing
+ # a query to the DB.
+ result = {
+ field: db_obj[field] for field in potential_fields
+ if (db_obj.get(field) is not None and
+ not issubclass(db_obj.get(field).__class__, sqla_query.Query))
+ }
for field, field_db in cls.fields_need_translation.items():
if field_db in result:
result[field] = result.pop(field_db)
@@ -933,5 +940,5 @@ class NeutronDbObject(NeutronObject, metaclass=DeclarativeObject):
cls.validate_filters(**kwargs)
# Succeed if at least a single object matches; no need to fetch more
return bool(obj_db_api.count(
- cls, context, **cls.modify_fields_to_db(kwargs))
+ cls, context, query_limit=1, **cls.modify_fields_to_db(kwargs))
)