Skip to content

Commit 7f6eb03

Browse files
fix comparison of xs:unsignedLong to xs:decimal (#2560)
1 parent 098d738 commit 7f6eb03

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

basex-core/src/main/java/org/basex/query/value/item/Uln.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,16 @@ public ANum round(final int prec, final RoundMode mode) {
8989
public boolean equal(final Item item, final Collation coll, final InputInfo ii)
9090
throws QueryException {
9191
return item.type == AtomType.UNSIGNED_LONG ? value.equals(((Uln) item).value) :
92-
item.type == AtomType.DOUBLE || item.type == AtomType.FLOAT ? item.equal(this, coll, ii) :
93-
value.compareTo(BigInteger.valueOf(item.itr(ii))) == 0;
92+
item.type == AtomType.DOUBLE || item.type == AtomType.FLOAT || item.type == AtomType.DECIMAL ?
93+
item.equal(this, coll, ii) :
94+
value.compareTo(BigInteger.valueOf(item.itr(ii))) == 0;
9495
}
9596

9697
@Override
9798
public int compare(final Item item, final Collation coll, final boolean transitive,
9899
final InputInfo ii) throws QueryException {
99100
return item.type == AtomType.UNSIGNED_LONG ? value.compareTo(((Uln) item).value) :
100-
item.type == AtomType.DOUBLE || item.type == AtomType.FLOAT ?
101+
item.type == AtomType.DOUBLE || item.type == AtomType.FLOAT || item.type == AtomType.DECIMAL ?
101102
-item.compare(this, coll, transitive, ii) :
102103
value.compareTo(BigInteger.valueOf(item.itr(ii)));
103104
}

basex-core/src/test/java/org/basex/query/simple/SimpleTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ public final class SimpleTest extends QueryTest {
3535
{ "Double 7", booleans(true), "xs:double('-INF') < 0" },
3636
{ "Double 8", "xs:double('-inf')" },
3737

38+
{ "UnsignedLong 1", booleans(false), "xs:unsignedLong('3') eq 3.1"},
39+
{ "UnsignedLong 2", booleans(false), "3.1 eq xs:unsignedLong('3')"},
40+
{ "UnsignedLong 3", booleans(true), "xs:unsignedLong(3) lt 3.1"},
41+
{ "UnsignedLong 4", booleans(true), "3.1 gt xs:unsignedLong(3)"},
42+
{ "UnsignedLong 5", integers(1), "compare(3.1, xs:unsignedLong('3'))"},
43+
{ "UnsignedLong 6", integers(-1), "compare(xs:unsignedLong('3'), 3.1)"},
44+
3845
{ "Annotation 1", integers(1), "declare %local:x(.1) variable $a := 1; $a" },
3946
{ "Annotation 2", integers(1), "declare %local:x(1.) variable $a := 1; $a" },
4047
{ "Annotation 3", "declare %local:x(.) variable $a := 1; $a" },

0 commit comments

Comments
 (0)