[COMPASS-4835] Compass export to languages does not allow template literals (backtick strings) Created: 19/May/21  Updated: 29/Oct/23  Resolved: 30/Aug/21

Status: Closed
Project: Compass
Component/s: Compass
Affects Version/s: None
Fix Version/s: 1.29.4

Type: Bug Priority: Major - P3
Reporter: Maurizio Casimirri Assignee: Le Roux Bodenstein
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to COMPASS-5112 $function NOT working in Node → Retur... Closed
Story Points: 5
Documentation Changes: Not Needed
Sprint: Iteration Johannesburg

 Description   

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.



 Comments   
Comment by Githook User [ 02/Sep/21 ]

Author:

{'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}

Message: fix: reformat the parsed query to turn functions into strings (COMPASS-4835) (#2420)
Branch: electron-13-same-keytar-node-14
https://github.com/mongodb-js/compass/commit/79fdbf2d01c6d3230f4dee0673ff33a73ad1c6cb

Comment by Githook User [ 30/Aug/21 ]

Author:

{'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}

Message: fix: reformat the parsed query to turn functions into strings (COMPASS-4835) (#2420)
Branch: main
https://github.com/mongodb-js/compass/commit/79fdbf2d01c6d3230f4dee0673ff33a73ad1c6cb

Generated at Wed Feb 07 22:37:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.