Problem with in-memory filtering of BigDecimal


while testing BigDecimal support for our fields we stumbled into this snippet from Compare.passesFilter():

        switch (getOperation()) {
        case EQUAL:
            return (null == this.value) ? (null == value) : this.value.equals(value);
        case GREATER:
            return compareValue(value) > 0;
        case LESS:
            return compareValue(value) < 0;

is there a particular reason for Compare.Equal to behave differently from the rest of the filters when dealing with Comparable values?
I mean, equals() for BigDecimal is not the right way to compare values (takes scale into account, i.e. it gives “1.0” != “1.00”). You need to use compareTo() to get a proper numerical comparison. For Comparable values, this is performed by compareValue() above… but it’s not used for Compare.Equal. So, this apparently breaks Compare.Equals for BigDecimal.

Is this a bug or a feature? I think the filter should use compareTo() if available, and then fall back to equals() for non-Comparable values.
Maybe there’s some catch so it can’t be done?

ticket #10310
for this issue.