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

include_root_in_json setting retrieval does not respect hierarchy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 7.0.6, 7.1.0
    • 7.1.1
    • Attributes
    • None

    Description

      ActiveModel has a knob called include_root_in_json (documented in https://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html) which controls the structure of the as_json method output. This knob is supported by Mongoid but its values are not being read correctly.

      Test case: https://github.com/p-mongo/tests/blob/master/mongoid-app/lib/tasks/test_4865.rake

      Output:

       
      Mongoid: false
      Foo: false
      foo: false
      Sub: false
      sub: false
       
      Mongoid -> true
       
      Mongoid: true
      Foo: false
      foo: true
      Sub: false
      sub: true
       
      Foo -> true
       
      Mongoid: false
      Foo: true
      foo: false
      Sub: true
      sub: false
       
      Sub -> true
       
      Mongoid: false
      Foo: false
      foo: false
      Sub: true
      sub: false
      
      

      The class level value is not influenced by the global Mongoid value, and the instance value is not influenced by the class level value.

      Attachments

        Issue Links

          Activity

            People

              oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
              oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: