$function computed field may be rewritten incorrectly

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The following may be rewritten by SERVER-105449.

      [
        {$lookup: {
          from: "ns",
          pipeline: [{$set: {time1: {$function: {
            body: function () {
              var now = Date.now();
              while (Date.now() === now) {}
              return new Date(now);
            },
            args: [], lang: "js",
          }}}}],
          as: "result",
        }},
        {$set: {time2: {$function: {
          body: function () { return new Date(); }, 
          args: [], lang: "js"
        }}}},
        {$match: {time2: ...}}
      ]
      

      One way to address this is to implement SERVER-124096 and to make the rewrite in SERVER-105449 conditional.

            Assignee:
            Unassigned
            Reporter:
            Vesko Karaganev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: