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

toString for traversals such as within with empty array returns empty string as argument instead of brackets

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.5.1
    • 3.6.0, 3.5.2
    • language
    • None

    Description

      I use the gremlin Translator to translate bytecode query to script in order to allow sending it to neptune profile/explain endpoints.

      a query which include a steps such as '.within([])'  , notice the empty array, is translated to 

      .within()   which fails in neptune, where  within([])  with empty brackets actually works.

      now I don't know if this is neptune blame which should allow such traversal or gremlin (client) issue, and if gremlin should print empty brackets or empty string..

      see: node_modules/gremlin/lib/process/traversal.js :

      return this.operator  '('  formatValue(this.value) + ')';

      .toString([])  => ''

       
       

      // 
        toString() {
          function formatValue(value){
            if (Array.isArray(value)) {
              let acc = [];
              for (const item of value) {
                acc.push(formatValue(item));
              }
              return acc;
            }
            if (value && typeof value === "string"){
              return "'" + value + "'";
            }
            return value;
          }
      
      
          if (this.other === undefined || this.other === null) {
            return this.operator + '(' + formatValue(this.value) + ')';
          }
          return this.operator + '(' + formatValue(this.value) + ', ' + formatValue(this.other) + ')';
        } 

       

       

      Attachments

        Activity

          People

            spmallette Stephen Mallette
            talron Tal Ron
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: