Commit 5147101 1 parent cd0a7bb commit 5147101 Copy full SHA for 5147101
File tree 2 files changed +8
-3
lines changed
metaconfig-core/shared/src/main/scala/metaconfig
metaconfig-tests/jvm/src/test/scala/metaconfig
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,8 @@ object Conf {
107
107
object Obj {
108
108
type Elem = (String , Conf )
109
109
val empty : Obj = Obj (Nil )
110
- def apply (values : Elem * ): Obj = Obj (values.toList)
110
+ def apply (values : Elem * ): Obj =
111
+ if (values.isEmpty) empty else Obj (values.toList)
111
112
}
112
113
113
114
def getEx [A ](state : A , conf : Conf , path : Seq [String ])(implicit
@@ -264,7 +265,11 @@ object ConfOps {
264
265
Iterable .concat(elemsA, elemsB).foldLeft(List .empty[Obj .Elem ]) {
265
266
case (merged, elemB @ (key, valB)) => merged
266
267
.collectFirst { case (`key`, valA) =>
267
- (key -> merge(valA, valB)) :: merged.filter(_._1 != key)
268
+ val filtered = merged.filter(_._1 != key)
269
+ merge(valA, valB) match {
270
+ case Conf .Obj (Nil ) => filtered
271
+ case x => (key -> x) :: filtered
272
+ }
268
273
}.getOrElse(elemB :: merged)
269
274
},
270
275
)
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class PatchSuite extends munit.FunSuite {
33
33
test(" patch with key and empty val: delete" ) {
34
34
val initial = Conf .Obj (" a" -> Conf .Num (0 ), " b" -> Conf .Str (" 1" ))
35
35
val patched = Conf .applyPatch(initial, Conf .Obj (" a" -> Conf .Obj .empty))
36
- assertEquals(patched, Conf .Obj (" a " -> Conf . Obj .empty, " b" -> Conf .Str (" 1" )))
36
+ assertEquals(patched, Conf .Obj (" b" -> Conf .Str (" 1" )))
37
37
}
38
38
39
39
}
You can’t perform that action at this time.
0 commit comments