Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2904

Forget to throw GremlinTypeErrorException when using is(predicate) to compare NaN

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Not A Bug
    • 3.6.2
    • None
    • process
    • None

    Description

      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))"

      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);
              }
      ... 

      Attachments

        Activity

          People

            Unassigned Unassigned
            miracy Miracy Cavendish
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: