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

Store values in declared field type

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Mongoid currently stores attribute values in the mongoized form. However, the application operates with these values in their declared field types, as does almost everything in Mongoid itself (everything except the actual write to the database). Repeated value conversions from mongoized form to the declared field type are inefficient for larger values (e.g. container types), and Mongoid “forgetting” about the produced value in the declared type makes it unaware of mutations of this value which is important for container types, as reported in https://jira.mongodb.org/browse/MONGOID-2951.

      Mongoid can store attribute values in the declared field type in addition to or, preferably, instead of storing them in the mongoized form.

      Storing the values only in declared field type is likely to be possible and would require no additional memory consumption while improving performance due to removal of demongoization upon attribute value access.

      To implement storage of values in declared field type, the typecast method must be separated from mongoize.

      Storing values in the declared field type is consistent with AR serialization behavior.

      Storing values in the declared field type will necessitate creating the missing intermediate values in the phantom custom field types use case. These values will then be the ones stored by Mongoid in #attributes etc. Type conversions could still be performed by a separate class.

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

              Created:
              Updated: