@@ -49,15 +49,38 @@ def __init__(self):
49
49
db_api .sqla_listen (se .Session , 'after_rollback' ,
50
50
self ._clear_rev_bumped_flags )
51
51
52
+ def _get_objects_to_bump_revision (self , dirty_objects ):
53
+ all_std_attr_objects = []
54
+ objects_to_bump_revision = []
55
+ for dirty_object in dirty_objects :
56
+ if isinstance (dirty_object , standard_attr .HasStandardAttributes ):
57
+ objects_to_bump_revision .append (dirty_object )
58
+ elif isinstance (dirty_object , standard_attr .StandardAttribute ):
59
+ all_std_attr_objects .append (dirty_object )
60
+
61
+ # Now as we have all objects divided into 2 groups, we need to ensure
62
+ # that we don't have revision number for the same one in both groups.
63
+ # It may happen e.g. for the Subnet object, as during update of Subnet,
64
+ # both Subnet and StandardAttribute objects of that subnet are dirty.
65
+ # But for example for Network, when only description is changed, only
66
+ # StandardAttribute object is in the dirty objects set.
67
+ std_attr_ids = [o .standard_attr_id for o in objects_to_bump_revision ]
68
+
69
+ # NOTE(slaweq): StandardAttribute objects which have "description"
70
+ # field modified, should have revision bumped too
71
+ objects_to_bump_revision += [
72
+ o for o in all_std_attr_objects
73
+ if ('description' not in o ._sa_instance_state .unmodified and
74
+ o .id not in std_attr_ids )]
75
+
76
+ return objects_to_bump_revision
77
+
52
78
def bump_revisions (self , session , context , instances ):
53
79
self ._enforce_if_match_constraints (session )
54
- # bump revision number for any updated objects in the session
80
+ # bump revision number for updated objects in the session
55
81
self ._bump_obj_revisions (
56
82
session ,
57
- [
58
- obj for obj in session .dirty
59
- if isinstance (obj , standard_attr .HasStandardAttributes )]
60
- )
83
+ self ._get_objects_to_bump_revision (session .dirty ))
61
84
62
85
# see if any created/updated/deleted objects bump the revision
63
86
# of another object
0 commit comments