JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Include has_many through: relationship fails
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 2.3k
- Fork
- 546
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo le richieste GET /users/1 elencate con le definizioni dei modelli User, Participation e Attempt, confrontando le risposte di include con query ActiveRecord dirette. Analizza la gestione delle relazioni has_many-through filtrate e l’ordine degli includes annidati; il lavoro è completato quando completed-attempts restituisce solo i tentativi completati e tutte le richieste elencate evitano un 500.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rails, ruby
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100