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

includes method bug

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      1.9.3p125 :010 > p = Elite::Post.includes(:author)
      => #<Mongoid::Criteria
        selector: {},
        options: {:sort=>{"created_at"=>1}},
        class: Elite::Post,
        embedded: false>

      1.9.3p125 :011 > p.map(&:inspect)
      => ["#<Elite::Post _id: 500533339e3e720063000002, _type: nil, created_at: 2012-07-17 09:41:07 UTC, updated_at: 2012-07-17 09:41:07 UTC, title: \"hello\", short: \"wassup\", full: \"\", keywords: \"\", description: \"\", user_id: \"4fc9fb1cbd7f1602ca000001\">"]
      1.9.3p125 :012 > p.map(&:inspect)
      => ["#<Elite::Post _id: 500533339e3e720063000002, _type: nil, created_at: nil, updated_at: nil, title: \"\", short: nil, full: \"\", keywords: nil, description: nil, user_id: \"4fc9fb1cbd7f1602ca000001\">"]
      1.9.3p125 :013 > p.any?
      => true
      1.9.3p125 :014 > p = Elite::Post.includes(:author)
      => #<Mongoid::Criteria
        selector: {},
        options: {:sort=>{"created_at"=>1}},
        class: Elite::Post,
        embedded: false>

      1.9.3p125 :015 > p.any?
      => true
      1.9.3p125 :016 > p.map(&:inspect)
      => ["#<Elite::Post _id: 500533339e3e720063000002, _type: nil, created_at: nil, updated_at: nil, title: \"\", short: nil, full: \"\", keywords: nil, description: nil, user_id: \"4fc9fb1cbd7f1602ca000001\">"]
      1.9.3p125 :017 > p = Elite::Post.all
      => #<Mongoid::Criteria
        selector: {},
        options: {:sort=>{"created_at"=>1}},
        class: Elite::Post,
        embedded: false>

      1.9.3p125 :018 > p.any?
      => true
      1.9.3p125 :019 > p.map(&:inspect)
      => ["#<Elite::Post _id: 500533339e3e720063000002, _type: nil, created_at: 2012-07-17 09:41:07 UTC, updated_at: 2012-07-17 09:41:07 UTC, title: \"hello\", short: \"wassup\", full: \"\", keywords: \"\", description: \"\", user_id: \"4fc9fb1cbd7f1602ca000001\">"]
      1.9.3p125 :020 > p.map(&:inspect)
      => ["#<Elite::Post _id: 500533339e3e720063000002, _type: nil, created_at: 2012-07-17 09:41:07 UTC, updated_at: 2012-07-17 09:41:07 UTC, title: \"hello\", short: \"wassup\", full: \"\", keywords: \"\", description: \"\", user_id: \"4fc9fb1cbd7f1602ca000001\">"]
      1.9.3p125 :021 >

      When we get collection with includes method and use like array (any?, map etc.) document fields are set to nil but only when field not recognized in .includes(:author) method.

      And the issue of Case sensitive validation still not solved.

            Assignee:
            Unassigned Unassigned
            Reporter:
            korzhyk korzhyk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: