Skip to content

Commit 76d220f

Browse files
committed
[bugfix] 4810-Fixed comparison and predicate execution
1 parent ba269cb commit 76d220f

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

exist-core/src/main/java/org/exist/xquery/Predicate.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,11 @@ private Sequence selectByNodeSet(final Sequence contextSequence) throws XPathExc
377377
final NodeSet contextSet = contextSequence.toNodeSet();
378378
final boolean contextIsVirtual = contextSet instanceof VirtualNodeSet;
379379
contextSet.setTrackMatches(false);
380-
final NodeSet nodes = super.eval(contextSet, null).toNodeSet();
380+
final Sequence x = super.eval(contextSet, null);
381+
if(!(x instanceof NodeSet))
382+
return x;
383+
final NodeSet nodes = result.toNodeSet();
384+
381385
/*
382386
* if the predicate expression returns results from the cache we can
383387
* also return the cached result.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
xquery version "3.1";
2+
3+
module namespace t="http://exist-db.org/xquery/test";
4+
5+
declare namespace test="http://exist-db.org/xquery/xqsuite";
6+
7+
declare variable $t:XML := document {
8+
<Y1 id="1">
9+
<H1 id="2" a2="2">true</H1>
10+
</Y1>
11+
};
12+
13+
declare
14+
%test:setUp
15+
function t:setup() {
16+
let $testCol := xmldb:create-collection("/db", "test")
17+
return
18+
xmldb:store("/db/test", "test.xml", $t:XML)
19+
};
20+
21+
declare
22+
%test:tearDown
23+
function t:tearDown() {
24+
xmldb:remove("/db/test")
25+
};
26+
27+
declare
28+
%test:assertTrue
29+
function t:test() {
30+
doc("/db/test/test.xml")//*[starts-with(@a2, "1") = false()]
31+
=> exists()
32+
};

0 commit comments

Comments
 (0)