mirror of https://github.com/databricks/cli.git
merge.Override: Fix handling of dyn.NilValue (#1530)
## Changes Fix handling of `dyn.NilValue` in `merge.Override` in case `dyn.Value` has location ## Tests Unit tests
This commit is contained in:
parent
cdd6fe8cb9
commit
dba6164a4c
|
@ -30,10 +30,6 @@ func Override(leftRoot dyn.Value, rightRoot dyn.Value, visitor OverrideVisitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func override(basePath dyn.Path, left dyn.Value, right dyn.Value, visitor OverrideVisitor) (dyn.Value, error) {
|
func override(basePath dyn.Path, left dyn.Value, right dyn.Value, visitor OverrideVisitor) (dyn.Value, error) {
|
||||||
if left == dyn.NilValue && right == dyn.NilValue {
|
|
||||||
return dyn.NilValue, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if left.Kind() != right.Kind() {
|
if left.Kind() != right.Kind() {
|
||||||
return visitor.VisitUpdate(basePath, left, right)
|
return visitor.VisitUpdate(basePath, left, right)
|
||||||
}
|
}
|
||||||
|
@ -98,9 +94,11 @@ func override(basePath dyn.Path, left dyn.Value, right dyn.Value, visitor Overri
|
||||||
} else {
|
} else {
|
||||||
return visitor.VisitUpdate(basePath, left, right)
|
return visitor.VisitUpdate(basePath, left, right)
|
||||||
}
|
}
|
||||||
|
case dyn.KindNil:
|
||||||
|
return left, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return dyn.InvalidValue, fmt.Errorf("unexpected kind %s", left.Kind())
|
return dyn.InvalidValue, fmt.Errorf("unexpected kind %s at %s", left.Kind(), basePath.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func overrideMapping(basePath dyn.Path, leftMapping dyn.Mapping, rightMapping dyn.Mapping, visitor OverrideVisitor) (dyn.Mapping, error) {
|
func overrideMapping(basePath dyn.Path, leftMapping dyn.Mapping, rightMapping dyn.Mapping, visitor OverrideVisitor) (dyn.Mapping, error) {
|
||||||
|
|
|
@ -330,9 +330,9 @@ func TestOverride_Primitive(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "nil (not updated)",
|
name: "nil (not updated)",
|
||||||
state: visitorState{},
|
state: visitorState{},
|
||||||
left: dyn.NilValue,
|
left: dyn.NilValue.WithLocation(leftLocation),
|
||||||
right: dyn.NilValue,
|
right: dyn.NilValue.WithLocation(rightLocation),
|
||||||
expected: dyn.NilValue,
|
expected: dyn.NilValue.WithLocation(leftLocation),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "nil (updated)",
|
name: "nil (updated)",
|
||||||
|
|
Loading…
Reference in New Issue