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

Inheritance _type overwritten on upsert

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

      Created a Shape and Circle < Shape model as documented in the documentation section on inheritance. Using

      Unable to find source-code formatter for language: circle. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      .new

      sets

      Unable to find source-code formatter for language: _type```. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
       correctly. Using update.collection with upsert true nullifies 

      _type

      . Is this expected? It does not seem correct to need to set 

      _type

       manually when upserting:
      
      

      bash
      1.9.2-p318 :036 > Circle.new(radius:6).save
      => true
      1.9.2-p318 :037 > Shape.all.last
      => #<Circle _id: 4f831ebd37492d7f52000003, _type: "Circle", x: nil, y: nil, radius: 6.0>
      1.9.2-p318 :038 > Circle.all.last
      => #<Circle _id: 4f831ebd37492d7f52000003, _type: "Circle", x: nil, y: nil, radius: 6.0>
      1.9.2-p318 :039 > Circle.collection.update(

      {radius: 6.0}

      ,

      {x:1, y:2, radius:3}

      ,

      {upsert: true}

      )
      => 103
      1.9.2-p318 :040 > Shape.all.last
      => #<Shape _id: 4f831ebd37492d7f52000003, _type: nil, x: 1, y: 2, radius: 3>
      1.9.2-p318 :041 > Circle.all.last
      => nil
      `
      I'm using mongoid 2.4.7.

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

              Created:
              Updated:
              Resolved: