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

Expand storage field names in index specification values

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 9.0.0
    • Affects Version/s: None
    • Component/s: None
    • None

      The values for index specification options, for example partial_filter_expression, could contain field names. Mongoid permits a user to specify that a field in their model should be stored as another field on the server(https://www.mongodb.com/docs/mongoid/master/reference/fields/#specifying-storage-field-names); this expansion is not currently performed for index specification option values but it should be.

      ------

      Original report:

      Tested on Mongoid 7.4.0

      A partial_filter_expression with an aliased field does not work.

      class Person
        include Mongoid::Document
        field :n, as: :name, type: String
      
        # BROKEN
        index({ name: 1 }, { partial_filter_expression: { name: { '$exists' => true } } })
      
        # works correctly
        index({ name: 1 }, { partial_filter_expression: { n: { '$exists' => true } } })
      end

            Assignee:
            jamis.buck@mongodb.com Jamis Buck
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: