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

Bug: exists? on embedded relations should only return true if the relation is persisted

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Associations
    • Labels:

      Given the following:

      class Person
        has_many :posts
        embeds_many :addresses
      end

      The following is the current behavior:

      person1 = Person.create!
      person1.posts.create!
      person1.posts.exists? #=> true       OK
      person1.addresses.create!
      person1.addresses.exists? #=> true   OK
      
      person1 = Person.create!
      person1.posts.build
      person1.posts.exists? #=> false      OK
      person1.addresses.build
      person1.addresses.exists? #=> true   BAD!

      The last line should return false, because the address is not yet persisted in the database.

            Assignee:
            jamis.buck@mongodb.com Jamis Buck
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: