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

updated_at field not populated on upsert.

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I'm running into issues with the updated_at field not being set when upserting a document:

      irb(main):001:0> class Foo; include Mongoid::Document; include Mongoid::Timestamps::Updated; field :foo, :type => String; end
      => #<Mongoid::Fields::Standard:0x007f58f50c96f8 @name="foo", @options={:type=>String, :klass=>Foo}, @label=nil, @default_val=nil>
      irb(main):002:0> f = Foo.new(:foo => "bar")
      => #<Foo _id: 53b5495d759b74db8d000002, updated_at: nil, foo: "bar">
      irb(main):003:0> f.upsert
      => true
      irb(main):004:0> Foo.where(:foo => "bar").first
      => #<Foo _id: 53b5495d759b74db8d000002, updated_at: nil, foo: "bar">
      

      I would expect an upsert to set this field. Is this the intended behaviour?

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            alext Alex Trepca
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: