JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Include has_many through: relationship fails
まだ誰も着手していません。
- 主要言語
- Ruby
- スター
- 2.3k
- フォーク
- 546
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
With the following set of models:
class User < ActiveRecord::Base
...
has_many :participations
has_many :attempts, through: :participations
has_many :completed_attempts, -> { completed }, through: :participations, source: :attempts
...
end
class Participation < ActiveRecord::Base
...
belongs_to :user
has_many :attempts
...
end
class Attempt < ActiveRecord::Base
...
belongs_to :participation
...
end
the request GET /users/1?include=completed-attempts fails. completed-attempts.txt.
Likewise, GET /users/1?include=completed-attempts,attempts fails. completed-attempts_attempts.txt
However, as expected, GET /users/1?include=attempts works. attempts.txt
Changing the order, GET /users/1?include=attempts,completed-attempts, doesn't fail with a 500, however it returns the full list of Attempts for both the attempts and completed-attempts relationships. attempts_completed-attempts.txt
Querying the relations directly from the AR object works correctly for both attempts and completed_attempts.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、User、Participation、Attempt のモデル定義を使って、列挙された GET /users/1 リクエストを再現し、include のレスポンスを直接の ActiveRecord クエリと比較します。フィルタリングされた has_many-through リレーションの処理と、ネストされた include の順序を調査します。completed-attempts が完了した Attempt のみを返し、列挙されたすべてのリクエストで 500 が発生しなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rails, ruby
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100