Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix associations associated with a CPK model by id attribute #47923

Merged

Commits on Apr 12, 2023

  1. Fix associations associated with a CPK model by id attribute

    Given a model associated with a composite primary key by `id` attribute,
    for example:
    ```ruby
    Order.primary_key = [:shop_id, :id]
    OrderAgreement.primary_key = :id
    
    Order.has_many :order_agreements, primary_key: :id
    ```
    
    Accessing the association should perform queries using
    the `id` attribute value and not the `id` as Order's composite primary key.
    
    ```ruby
    order = Order.last # => #<Order id: 1, shop_id: 2>
    
    order.order_agreements.to_a
    ```
    nvasilevski committed Apr 12, 2023
    Configuration menu
    Copy the full SHA
    5cbdfba View commit details
    Browse the repository at this point in the history