Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-4835

Compass export to languages does not allow template literals (backtick strings)

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.29.4
    • Affects Version/s: None
    • Component/s: Compass
    • None
    • 5
    • Not Needed
    • Iteration Johannesburg

      Compass export to languages breaks with template literals (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)

      This happens with basic examples from the mongodb docs:

      [{
          $addFields: {
              isFound: {
                  $function: {
                      body: function(name) {
                          return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad";
                      },
                      args: ["$name"],
                      lang: "js"
                  }
              },
              message: {
                  $function: {
                      body: function(name, scores) {
                          let total = Array.sum(scores);
                          return `Hello ${name}.  Your total score is ${total}.`;
                      },
                      args: ["$name", "$scores"],
                      lang: "js"
                  }
              }
          }
      }]
      

      There is no need for the export to language to parse the body of a function, ideally we should just avoid doing that. If that is not possible we may at least want to support template literals in our grammar.

            Assignee:
            leroux.bodenstein@mongodb.com Le Roux Bodenstein
            Reporter:
            maurizio.casimirri@mongodb.com Maurizio Casimirri
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: