@@ -187,19 +187,17 @@ func (v *reconcileWithSchemaWalker) visitListItems(t *schema.List, element *fiel
187
187
}
188
188
189
189
func (v * reconcileWithSchemaWalker ) doList (t * schema.List ) (errs ValidationErrors ) {
190
- // reconcile lists changed from granular to atomic
190
+ // reconcile lists changed from granular to atomic.
191
+ // Note that migrations from atomic to granular are not recommended and will
192
+ // be treated as if they were always granular.
193
+ //
194
+ // In this case, the manager that owned the previously atomic field (and all subfields),
195
+ // will now own just the top-level field and none of the subfields.
191
196
if ! v .isAtomic && t .ElementRelationship == schema .Atomic {
192
197
v .toRemove = fieldpath .NewSet (v .path ) // remove all root and all children fields
193
198
v .toAdd = fieldpath .NewSet (v .path ) // add the root of the atomic
194
199
return errs
195
200
}
196
- // reconcile lists changed from atomic to granular
197
- if v .isAtomic && t .ElementRelationship == schema .Associative {
198
- v .toAdd , errs = buildGranularFieldSet (v .path , v .value )
199
- if errs != nil {
200
- return errs
201
- }
202
- }
203
201
if v .fieldSet != nil {
204
202
errs = v .visitListItems (t , v .fieldSet )
205
203
}
@@ -231,42 +229,25 @@ func (v *reconcileWithSchemaWalker) visitMapItems(t *schema.Map, element *fieldp
231
229
}
232
230
233
231
func (v * reconcileWithSchemaWalker ) doMap (t * schema.Map ) (errs ValidationErrors ) {
234
- // reconcile maps and structs changed from granular to atomic
232
+ // reconcile maps and structs changed from granular to atomic.
233
+ // Note that migrations from atomic to granular are not recommended and will
234
+ // be treated as if they were always granular.
235
+ //
236
+ // In this case the manager that owned the previously atomic field (and all subfields),
237
+ // will now own just the top-level field and none of the subfields.
235
238
if ! v .isAtomic && t .ElementRelationship == schema .Atomic {
236
239
if v .fieldSet != nil && v .fieldSet .Size () > 0 {
237
240
v .toRemove = fieldpath .NewSet (v .path ) // remove all root and all children fields
238
241
v .toAdd = fieldpath .NewSet (v .path ) // add the root of the atomic
239
242
}
240
243
return errs
241
244
}
242
- // reconcile maps changed from atomic to granular
243
- if v .isAtomic && (t .ElementRelationship == schema .Separable || t .ElementRelationship == "" ) {
244
- v .toAdd , errs = buildGranularFieldSet (v .path , v .value )
245
- if errs != nil {
246
- return errs
247
- }
248
- }
249
245
if v .fieldSet != nil {
250
246
errs = v .visitMapItems (t , v .fieldSet )
251
247
}
252
248
return errs
253
249
}
254
250
255
- func buildGranularFieldSet (path fieldpath.Path , value * TypedValue ) (* fieldpath.Set , ValidationErrors ) {
256
-
257
- valueFieldSet , err := value .ToFieldSet ()
258
- if err != nil {
259
- return nil , errorf ("toFieldSet: %v" , err )
260
- }
261
- if valueFieldSetAtPath , ok := fieldSetAtPath (valueFieldSet , path ); ok {
262
- result := fieldpath .NewSet (path )
263
- resultAtPath := descendToPath (result , path )
264
- * resultAtPath = * valueFieldSetAtPath
265
- return result , nil
266
- }
267
- return nil , nil
268
- }
269
-
270
251
func fieldSetAtPath (node * fieldpath.Set , path fieldpath.Path ) (* fieldpath.Set , bool ) {
271
252
ok := true
272
253
for _ , pe := range path {
0 commit comments