Storing a Date inside a field of type Array returns a Time

XMLWordPrintableJSON

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

      We store a field of variable types. It can be an array of String, Date or Time in any quantity and combinations.

       ruby
      class Artwork
        include Mongoid::Document
      
        field :dates, type: Array
      end
      

      Mongoid 2.x

       ruby
      Artwork.new({ dates: [ Date.parse("3/5/2011") ]}).dates.first.class
       => Date
      

      Mongoid 3.x

       ruby
      Artwork.new({ dates: [ Date.parse("3/5/2011") ]}).dates.first.class
       => Time 
      

      Is this by design or a bug? I would expect that storing a date returns a date. Is there an easy way to get old behavior back?

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

                Created:
                Updated:
                Resolved: