Skip to content

Commit b951d8e

Browse files
committed
[bugfix] Return alse instead of () in GeneralComparison when no operands match (#4958)
1 parent 3bf9db6 commit b951d8e

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

exist-core/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@
766766
<include>src/test/java/org/exist/xquery/functions/xmldb/XMLDBStoreTest.java</include>
767767
<include>src/test/java/org/exist/xquery/functions/xquery3/SerializeTest.java</include>
768768
<include>src/test/java/org/exist/xquery/value/DateTimeTypesTest.java</include>
769+
<include>src/test/xquery/emptySeq.xq</include>
769770
</includes>
770771
</licenseSet>
771772

@@ -1085,6 +1086,7 @@
10851086
<include>src/main/java/org/exist/xslt/EXistURIResolver.java</include>
10861087
<include>src/main/java/org/exist/xslt/XsltURIResolverHelper.java</include>
10871088
<include>src/test/java/org/exist/xupdate/RemoveAppendTest.java</include>
1089+
<include>src/main/java/org/exist/xquery/GeneralComparison.java</include>
10881090
</includes>
10891091
</licenseSet>
10901092

@@ -1538,7 +1540,8 @@
15381540
<exclude>src/main/java/org/exist/xslt/EXistURIResolver.java</exclude>
15391541
<exclude>src/main/java/org/exist/xslt/XsltURIResolverHelper.java</exclude>
15401542
<exclude>src/test/java/org/exist/xupdate/RemoveAppendTest.java</exclude>
1541-
1543+
<exclude>src/main/java/org/exist/xquery/GeneralComparison.java</exclude>
1544+
<exclude>src/test/xquery/emptySeq.xq</exclude>
15421545
<!--
15431546
Derivative work licensed under dbXML 1.0 and LGPL 2.1
15441547
-->

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
/*
2+
* Elemental
3+
* Copyright (C) 2024, Evolved Binary Ltd
4+
*
5+
6+
* https://www.evolvedbinary.com | https://www.elemental.xyz
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; version 2.1.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
22+
* The original license header is included below.
23+
*
24+
* =====================================================================
25+
*
226
* eXist-db Open Source Native XML Database
327
* Copyright (C) 2001 The eXist-db Authors
428
*
@@ -648,6 +672,9 @@ protected Sequence nodeSetCompare( NodeSet nodes, Sequence contextSequence ) thr
648672
}
649673
}
650674
}
675+
if (result.isEmpty()) {
676+
return BooleanValue.FALSE;
677+
}
651678
}
652679

653680
if( context.getProfiler().traceFunctions() ) {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
(:
2+
: Elemental
3+
: Copyright (C) 2024, Evolved Binary Ltd
4+
:
5+
6+
: https://www.evolvedbinary.com | https://www.elemental.xyz
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; version 2.1.
11+
:
12+
: This library is distributed in the hope that it will be useful,
13+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
: Lesser General Public License for more details.
16+
:
17+
: You should have received a copy of the GNU Lesser General Public
18+
: License along with this library; if not, write to the Free Software
19+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
:)
21+
xquery version "3.1";
22+
23+
module namespace t="http://exist-db.org/xquery/test";
24+
25+
declare namespace test="http://exist-db.org/xquery/xqsuite";
26+
27+
declare variable $t:XML := document {
28+
<F id="1"/>
29+
};
30+
31+
declare
32+
%test:setUp
33+
function t:setup() {
34+
xmldb:create-collection("/db", "test"),
35+
xmldb:store("/db/test", "test.xml", $t:XML)
36+
};
37+
38+
declare
39+
%test:tearDown
40+
function t:tearDown() {
41+
xmldb:remove("/db/test")
42+
};
43+
44+
declare
45+
%test:assertTrue
46+
function t:test-db() {
47+
exists(
48+
doc("/db/test/test.xml")//F[boolean(count(@id >= 2))]
49+
)
50+
};
51+
52+
declare
53+
%test:assertTrue
54+
function t:test-mem() {
55+
exists(
56+
$t:XML//F[boolean(count(@id >= 2))]
57+
)
58+
};

0 commit comments

Comments
 (0)