@@ -187,19 +187,17 @@ func (v *reconcileWithSchemaWalker) visitListItems(t *schema.List, element *fiel
187187}
188188
189189func  (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. 
191196	if  ! v .isAtomic  &&  t .ElementRelationship  ==  schema .Atomic  {
192197		v .toRemove  =  fieldpath .NewSet (v .path ) // remove all root and all children fields 
193198		v .toAdd  =  fieldpath .NewSet (v .path )    // add the root of the atomic 
194199		return  errs 
195200	}
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- 	}
203201	if  v .fieldSet  !=  nil  {
204202		errs  =  v .visitListItems (t , v .fieldSet )
205203	}
@@ -231,42 +229,25 @@ func (v *reconcileWithSchemaWalker) visitMapItems(t *schema.Map, element *fieldp
231229}
232230
233231func  (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. 
235238	if  ! v .isAtomic  &&  t .ElementRelationship  ==  schema .Atomic  {
236239		if  v .fieldSet  !=  nil  &&  v .fieldSet .Size () >  0  {
237240			v .toRemove  =  fieldpath .NewSet (v .path ) // remove all root and all children fields 
238241			v .toAdd  =  fieldpath .NewSet (v .path )    // add the root of the atomic 
239242		}
240243		return  errs 
241244	}
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- 	}
249245	if  v .fieldSet  !=  nil  {
250246		errs  =  v .visitMapItems (t , v .fieldSet )
251247	}
252248	return  errs 
253249}
254250
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- 
270251func  fieldSetAtPath (node  * fieldpath.Set , path  fieldpath.Path ) (* fieldpath.Set , bool ) {
271252	ok  :=  true 
272253	for  _ , pe  :=  range  path  {
0 commit comments