Miracy Cavendish created TINKERPOP-2904:
-------------------------------------------

             Summary: Forget to throw GremlinTypeErrorException when using 
is(predicate) to compare NaN 
                 Key: TINKERPOP-2904
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2904
             Project: TinkerPop
          Issue Type: Bug
    Affects Versions: 3.5.5
            Reporter: Miracy Cavendish


By the design of Gremlin, an exception should be thrown when comparison with 
NaN.
However, I found that when using ```is(predicate)``` to compare, the exception 
is always swallowed, and this issue occurs on all GDBs support Gremlin.
```
g.inject(Double.NaN).is(gt(3))
```
{code:java}
public static final GremlinValueComparator COMPARABILITY = new 
GremlinValueComparator() {

        /**
         * Compare two Gremlin value objects per the Comparability semantics. 
Throws type errors for NaN comparison
         * and for cross-type comparison (including nulltype).
         *
         * Use this method for P.lt/lte/gt/gte.
         */
        @Override
        public int compare(final Object f, final Object s) {
            // For Compare, NaN always produces ERROR
            if (eitherAreNaN(f, s))
                throwTypeError();

            // For Compare we do not cross type boundaries, including null
            if (!comparable(f, s))
                throwTypeError();

            // comparable(f, s) assures that type(f) == type(s)
            final Type type = Type.type(f);
            return comparator(type).compare(f, s);
        }
... {code}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to