Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-3132

Immediately execute aggregation pipeline when write stages are used

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      When creating an aggregation pipeline using Collection.aggregate, the result is a lazy object that won't run the aggregation pipeline until iteration has started. This is fine for pipelines where users expect a result to be returned, but for pipelines using a write stage (e.g. $merge or $out), this behaviour is problematic as there is no expectations for users to work with the return value of Collection.aggregate.

      In my case, it took me several attempts to figure out why my aggregation pipeline wasn't run and I had to resort to calling Collection.aggregate(...).to_a to ensure the pipeline was created. This could be avoided by checking the last pipeline stage and disabling lazy execution if it is a write stage.

            Assignee:
            Unassigned Unassigned
            Reporter:
            andreas.braun@mongodb.com Andreas Braun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: