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

upsert doesn't flaged new_record

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

      I'm using mongoid 3.1.4.
      This causes unexpected validation error, like this

      > class Hoge; include Mongoid::Document; field :name, type: String; validates :name, uniqueness: true; end
      => {:uniqueness=>true}
      > h = Hoge.new(name: 'foobar')
      => #<Hoge _id: 51df9674d53e43ebb0000003, created_at: nil, updated_at: nil, deleted_at: nil, name: "foobar", sheet_id: nil, kase_id: nil>
      > h.upsert
      => true
      > h.new_record?
      => true
      > h.name = 'piyo'
      => "piyo"
      > h.upsert
      => false
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            dot Shuhei KONDO
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: