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

Array/Hash fields should fail somehow when assigned the wrong type.

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

      Using Mongoid 3.0.6.

      class Cow
      include Mongoid::Document

      field :hash, :type => Hash
      field :array, :type => Array
      end

      Cow.create(:hash => ['a', 'b'], :array => {:i => 2})
      => #<Cow _id: 50711b98f4d5d4ee0e000002, _type: nil, hash: ["a", "b"], array: {:i=>2}>

      This is sort of worrisome. Is there a way to prevent this?

            Assignee:
            durran Durran Jordan
            Reporter:
            pschuegr pschuegr
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: