Skip to content

[bugfix] #4958 & #4810 #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop-7.x.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ protected Sequence nodeSetCompare( NodeSet nodes, Sequence contextSequence ) thr
}
}
}
if (result.isEmpty()) {
return BooleanValue.FALSE;
}
}

if( context.getProfiler().traceFunctions() ) {
Expand Down
10 changes: 9 additions & 1 deletion exist-core/src/main/java/org/exist/xquery/Predicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.exist.xquery.value.SequenceIterator;
import org.exist.xquery.value.Type;
import org.exist.xquery.value.ValueSequence;
import org.exist.xquery.value.BooleanValue;

import javax.annotation.Nullable;
import java.util.Set;
Expand Down Expand Up @@ -377,7 +378,14 @@ private Sequence selectByNodeSet(final Sequence contextSequence) throws XPathExc
final NodeSet contextSet = contextSequence.toNodeSet();
final boolean contextIsVirtual = contextSet instanceof VirtualNodeSet;
contextSet.setTrackMatches(false);
final NodeSet nodes = super.eval(contextSet, null).toNodeSet();
final Sequence res = super.eval(contextSet, null);
if(!(res instanceof NodeSet)) {
if(res == BooleanValue.FALSE)
return NodeSet.EMPTY_SET;
return res;
}
final NodeSet nodes = res.toNodeSet();

/*
* if the predicate expression returns results from the cache we can
* also return the cached result.
Expand Down
38 changes: 38 additions & 0 deletions exist-core/src/test/xquery/emptySeq.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
xquery version "3.1";

module namespace t="http://exist-db.org/xquery/test";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $t:XML := document {
<F id="1"/>
};

declare
%test:setUp
function t:setup() {
xmldb:create-collection("/db", "test"),
xmldb:store("/db/test", "test.xml", $t:XML)
};

declare
%test:tearDown
function t:tearDown() {
xmldb:remove("/db/test")
};

declare
%test:assertTrue
function t:test-db() {
exists(
doc("/db/test/test.xml")//F[boolean(count(@id >= 2))]
)
};

declare
%test:assertTrue
function t:test-mem() {
exists(
$t:XML//F[boolean(count(@id >= 2))]
)
};
32 changes: 32 additions & 0 deletions exist-core/src/test/xquery/startWithComp.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
xquery version "3.1";

module namespace t="http://exist-db.org/xquery/test";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare variable $t:XML := document {
<Y1 id="1">
<H1 id="2" a2="2">true</H1>
</Y1>
};

declare
%test:setUp
function t:setup() {
let $testCol := xmldb:create-collection("/db", "test")
return
xmldb:store("/db/test", "test.xml", $t:XML)
};

declare
%test:tearDown
function t:tearDown() {
xmldb:remove("/db/test")
};

declare
%test:assertTrue
function t:test() {
doc("/db/test/test.xml")//*[starts-with(@a2, "1") = false()]
=> exists()
};
Loading