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

Updating polymorphic embed executes wrong query

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

      Hi, I've got this document:

      class CourierJob
      include Mongoid::Document
      embeds_one :drop_address, as: :addressable, autobuild: true, class_name: "Addresses::ShipmentAddress"
      end

      now when i execute

      Unable to find source-code formatter for language: update_attribute. 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
      (:drop_address, some address object)

      on a CourierJob instance I can see the following in the rails logfile:

      MOPED: 127.0.0.1:27017 UPDATE database=project_test collection=courier_jobs selector=

      {"_id"=>BSON::ObjectId('537e0b50476f6c1b19190000')}

      update={"$set"=>{"address"=>

      {"_id"=>BSON::ObjectId('537e0b50476f6c1b191c0000'), "_type"=>"Addresses::ShipmentAddress", ....}

      }}

      The part i am worried about is

      Unable to find source-code formatter for language: update. 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
      ={"$set"=>{"address"=>

      because it should be

      Unable to find source-code formatter for language: update. 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
      ={"$set"=>{"drop_address"=>

      The address model looks like this:

      class Address
      include Mongoid::Document
      embedded_in :addressable, polymorphic: true
      end

      class ShipmentAddress < Address
      ...
      end

      Is there something I am doing wrong or is this a bug?

      PS: if i do

      .drop_address

      on the same object right after the

      Unable to find source-code formatter for language: update_attribute```. 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
       it gives me the correct result. After a reload from the db the the value is again the one from before 

      update_attribute{{`}}

            Assignee:
            dianna.hohensee@mongodb.com Dianna Hohensee (Inactive)
            Reporter:
            Goltergaul Goltergaul [X]
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: