Skip to content

Commit a4a17d4

Browse files
[FIX] Regression in map implementation. Closes #2615
1 parent 020cd9a commit a4a17d4

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

basex-core/src/main/java/org/basex/query/value/map/TrieBranch.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ TrieNode remove(final int hs, final int lv, final TrieUpdate update) throws Quer
7070
} else {
7171
nu = used;
7272
}
73+
// single leaf remains
74+
if(size == 2) return nsub;
75+
// create new array, replace child
7376
final TrieNode[] ks = kids.clone();
7477
ks[k] = nsub;
7578
return new TrieBranch(ks, nu, size - 1);

basex-core/src/test/java/org/basex/query/func/MapModuleTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ record = "declare record local:x(x as xs:integer);";
515515
// GH-2438
516516
query("let $f := fn($map) { fold-left(map:keys($map), $map, map:remove#2) } " +
517517
"return $f({ 'a': () })", "{}");
518+
// GH-2615
519+
query("{ 'aa': 1, 'bb': 2, 'cc': 3 } => map:remove('aa') => map:remove('bb')", "{\"cc\":3}");
520+
query("{ 'aa': 1, 'bb': 2, 'cc': 3 } => map:remove('aa') => map:remove('cc')", "{\"bb\":2}");
521+
query("{ 'aa': 1, 'bb': 2, 'cc': 3 } => map:remove('bb') => map:remove('cc')", "{\"aa\":1}");
518522
}
519523

520524
/** Test method. */

0 commit comments

Comments
 (0)