Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5003

Delegate Model#find with block argument to Enumerable#find

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Query
    • Labels:

      Description

      https://jira.mongodb.org/browse/MONGOID-4914 implemented delegation of association#find to Enumerable#find to filter the association in application process space.

      The same can be done for top-level model classes.

      Example code demonstrating the problem:

      irb(main):005:0> Band.find { |x| p x }
      => nil
      

      Here I expected the block to be called for each band and the first band to be returned, but I got nil and the block was not invoked.

      See also the discussion in https://github.com/mongodb/mongoid/pull/4802.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              oleg.pudeyev Oleg Pudeyev
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: