@@ -2,6 +2,7 @@ package dresources
22
33import (
44 "fmt"
5+ "maps"
56 "reflect"
67
78 "github.com/databricks/cli/libs/structs/structaccess"
@@ -72,16 +73,16 @@ func compileCopier(remoteType, stateType reflect.Type) (*copier, error) {
7273 }
7374 switch {
7475 case dst .typ == src .typ :
75- ops = append (ops , copyOp {dstIndex : dst .index , srcIndex : src .index , dstType : dst .typ })
76+ ops = append (ops , copyOp {forceSendFields : false , dstIndex : dst .index , srcIndex : src .index , convert : false , dstType : dst .typ , ownerType : nil })
7677 case safeConvert (dst .typ , src .typ ):
77- ops = append (ops , copyOp {dstIndex : dst .index , srcIndex : src .index , convert : true , dstType : dst .typ })
78+ ops = append (ops , copyOp {forceSendFields : false , dstIndex : dst .index , srcIndex : src .index , convert : true , dstType : dst .typ , ownerType : nil })
7879 default :
7980 return nil , fmt .Errorf ("field %q: state type %s cannot be copied from remote type %s; implement RemapState" , name , dst .typ , src .typ )
8081 }
8182 }
8283
8384 for _ , target := range dstForceSend {
84- ops = append (ops , copyOp {forceSendFields : true , dstIndex : target .index , ownerType : target .ownerType })
85+ ops = append (ops , copyOp {forceSendFields : true , dstIndex : target .index , srcIndex : nil , convert : false , dstType : nil , ownerType : target .ownerType })
8586 }
8687
8788 return & copier {stateElem : stateElem , ops : ops }, nil
@@ -101,7 +102,7 @@ func rootForceSendFields(remote reflect.Value) []string {
101102 if ! f .IsValid () || f .Kind () != reflect .Slice {
102103 return nil
103104 }
104- fields , _ := f . Interface ().([ ]string )
105+ fields , _ := reflect. TypeAssert [[ ]string ]( f )
105106 return fields
106107}
107108
@@ -152,9 +153,7 @@ func flattenStruct(t reflect.Type, prefix []int) (map[string]jsonFieldInfo, []fo
152153 }
153154 if structaccess .IsFlattenedEmbed (sf ) {
154155 nested , nestedForceSend := flattenStruct (sf .Type , index )
155- for name , info := range nested {
156- fields [name ] = info
157- }
156+ maps .Copy (fields , nested )
158157 forceSend = append (forceSend , nestedForceSend ... )
159158 continue
160159 }
0 commit comments