Document using Mongoid::Timestamps does not persist its embeds_one documents

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Unknown
    • None
    • Affects Version/s: 9.1.0
    • Component/s: None
    • None
    • None
    • Ruby Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Documents using Mongoid::Timestamps do not persist their embeds_one documents.

      A/B (without Timestamps), X/Y (with Timestamps) :

       

      ::Object.send(:remove_const, :A)
      ::Object.send(:remove_const, :B)
      ::Object.send(:remove_const, :X)
      ::Object.send(:remove_const, :Y)
      
      
      class A
        include ::Mongoid::Document
      
      
        embeds_one :b
      end
      
      
      class B
        include ::Mongoid::Document
      
      
        embedded_in :a
      end
      
      
      class X
        include ::Mongoid::Document
        include ::Mongoid::Timestamps # <-----------------------------     
      
        embeds_one :y
      end
      
      
      class Y
        include ::Mongoid::Document
      
      
        embedded_in :x
      end
      
      
      puts(
        [
          ::Mongoid::VERSION,
          nil,
          a = ::A.create!,
          a.create_b,
          a.reload.b,
          a.delete,
          nil,
          x = ::X.create!,
          x.create_y,
          x.reload.y,
          x.delete
        ].map(&:inspect)
      ) 

      "Y" document persisted using Mongoid 9.0.11

      "9.0.11"
      nil
      #<A _id: 6a552cc6c20215549c264565, >
      #<B _id: 6a552cc6c20215549c264566, >
      #<B _id: 6a552cc6c20215549c264566, >
      true
      nil
      #<X _id: 6a552cc6c20215549c264567, created_at: 2026-07-13 18:21:58.53 UTC, updated_at: 2026-07-13 18:21:58.533 UTC>
      #<Y _id: 6a552cc6c20215549c264568, >
      #<Y _id: 6a552cc6c20215549c264568, >
      true 

      "Y" document NOT persisted using Mongoid 9.1.0

      "9.1.0"
      nil
      #<A _id: 6a552c8f4f4cd6ca495a7bb6, >
      #<B _id: 6a552c8f4f4cd6ca495a7bb7, >
      #<B _id: 6a552c8f4f4cd6ca495a7bb7, >
      true
      nil
      #<X _id: 6a552c8f4f4cd6ca495a7bb8, created_at: 2026-07-13 18:21:03.575 UTC, updated_at: 2026-07-13 18:21:03.581 UTC>
      #<Y _id: 6a552c8f4f4cd6ca495a7bb9, >
      nil # <-----------------------------
      true 

       

            Assignee:
            Dmitry Rybakov
            Reporter:
            Sylvain Bernier (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: