[
https://issues.apache.org/jira/browse/TINKERPOP-2904?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Yang Xia updated TINKERPOP-2904:
--------------------------------
Affects Version/s: 3.6.2
(was: 3.5.5)
> 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
> Components: process
> Affects Versions: 3.6.2
> Reporter: Miracy Cavendish
> Priority: Critical
>
> By the design of Gremlin, an exception should be thrown when compared 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, such as "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)