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

index macro does not expand HABTM associations

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 7.1.5
    • Component/s: Associations
    • None
    • Environment:
      Rails

      When creating a compound index on a HABTM field, the index key is not singular and does not have _ids suffix

       

       

      belongs_to :project
      has_and_belongs_to_many :users, index: true
      # => {"user_ids"=>1},
      index({ project: 1, users: 1 })
      # => {"project_id"=>1, "users"=>1}, #
      # whereas this produces the good key name
      index({ project: 1, relations[:users].foreign_key: 1 })
      # => {"project_id"=>1, "user_ids"=>1},
      

      ```

            Assignee:
            Unassigned Unassigned
            Reporter:
            CyrilDD Cyril
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: