Model JavaScript / code dependency in DepsTracker

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

      We should model the JavaScript dependency. If DepsTracker had needJsEnv, or something more general like needRandomGenerator, that could prevent this incorrect rewrite.

      [
        {$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"
        }}}},
      ]

      In the above example, the two $function blocks always read a different time, and time1 < time2.

      If the $set is hoisted before the $lookup, time2 < time1.

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

              Created:
              Updated: