CodeWScope not working in reduce function for M/R

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 1.7.2
    • Affects Version/s: None
    • Component/s: JavaScript
    • None
    • Environment:
      Ruby 1.8 / Ruby 1.9
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      With $where you can do something like:

      posts.find($where => Code.new("i < 3",

      {i: 2}

      ))

      and there will be scope created with i variable set to 2 fror "i < 3" part.

      However, this doesn't work with map-reduce functions.

      map = "function() { emit(this._id,

      {foo: 'bar'); }

      "
      reduce = Code.new(
      "function(key, values)

      { return x; }

      ",

      {x: 1}

      )
      posts.map_reduce(map, reduce)

      This throws an error like:
      map-reduce failed: assertion: invoke failed: JS Error: ReferenceError: x is not defined nofile_b:3

              Assignee:
              Tony Hannan (Inactive)
              Reporter:
              Hubert Lepicki
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: