From 756462cb26708223b03b001874b1f25fa525acea Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Wed, 9 Oct 2024 02:11:16 +0200 Subject: [PATCH] [bugfix] Fix Math ops on xs:integer from xs:numeric --- .../java/org/exist/xquery/value/IntegerValue.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java b/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java index 9833e0367a0..a2e36d95e2d 100644 --- a/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java +++ b/exist-core/src/main/java/org/exist/xquery/value/IntegerValue.java @@ -377,7 +377,7 @@ public NumericValue round(final IntegerValue precision) throws XPathException { @Override public ComputableValue minus(final ComputableValue other) throws XPathException { - if (Type.subTypeOf(other.getType(), Type.INTEGER)) + if (Type.subTypeOf(other.getType(), Type.INTEGER) || (other instanceof IntegerValue && other.getType() == Type.NUMERIC)) // return new IntegerValue(value - ((IntegerValue) other).value, type); { return new IntegerValue(getExpression(), value.subtract(((IntegerValue) other).value), type); @@ -388,7 +388,7 @@ public ComputableValue minus(final ComputableValue other) throws XPathException @Override public ComputableValue plus(final ComputableValue other) throws XPathException { - if (Type.subTypeOf(other.getType(), Type.INTEGER)) + if (Type.subTypeOf(other.getType(), Type.INTEGER) || (other instanceof IntegerValue && other.getType() == Type.NUMERIC)) // return new IntegerValue(value + ((IntegerValue) other).value, type); { return new IntegerValue(getExpression(), value.add(((IntegerValue) other).value), type); @@ -399,7 +399,7 @@ public ComputableValue plus(final ComputableValue other) throws XPathException { @Override public ComputableValue mult(final ComputableValue other) throws XPathException { - if (Type.subTypeOf(other.getType(), Type.INTEGER)) { + if (Type.subTypeOf(other.getType(), Type.INTEGER) || (other instanceof IntegerValue && other.getType() == Type.NUMERIC)) { return new IntegerValue(getExpression(), value.multiply(((IntegerValue) other).value), type); } else if (Type.subTypeOf(other.getType(), Type.DURATION)) { return other.mult(this); @@ -443,7 +443,7 @@ public IntegerValue idiv(final NumericValue other) throws XPathException { @Override public NumericValue mod(final NumericValue other) throws XPathException { - if (Type.subTypeOf(other.getType(), Type.INTEGER)) { + if (Type.subTypeOf(other.getType(), Type.INTEGER) || (other instanceof IntegerValue && other.getType() == Type.NUMERIC)) { if (other.isZero()) { throw new XPathException(getExpression(), ErrorCodes.FOAR0001, "division by zero"); } @@ -468,7 +468,7 @@ public NumericValue abs() throws XPathException { @Override public AtomicValue max(final Collator collator, final AtomicValue other) throws XPathException { - if (Type.subTypeOf(other.getType(), Type.INTEGER)) { + if (Type.subTypeOf(other.getType(), Type.INTEGER) || (other instanceof IntegerValue && other.getType() == Type.NUMERIC)) { return new IntegerValue(getExpression(), value.max(((IntegerValue) other).value)); } else { return convertTo(other.getType()).max(collator, other); @@ -477,7 +477,7 @@ public AtomicValue max(final Collator collator, final AtomicValue other) throws @Override public AtomicValue min(final Collator collator, final AtomicValue other) throws XPathException { - if (Type.subTypeOf(other.getType(), Type.INTEGER)) { + if (Type.subTypeOf(other.getType(), Type.INTEGER) || (other instanceof IntegerValue && other.getType() == Type.NUMERIC)) { return new IntegerValue(getExpression(), value.min(((IntegerValue) other).value)); } else { return convertTo(other.getType()).min(collator, other);