JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Included resource choosing wrong Arel table
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
I'm running into an issue where including one resource (user) ends up using another Arel table (account), and thus the include blows up with Internal Server Error: key not found: 11. 11 is the Account ID of the user, but the user ID is 68, which is specified on the parent resource as user_id.
I've stepped through the code a bit to determine that pluck_attrs in JSONAPI::Resource#preload_include_fragments has the wrong Arel::Table but I'm not sure what the cause of that is.
My models and resources are configured in a very straightforward manner:
JobApplication < ApplicationRecord
belongs_to :user, inverse_of: :job_applications, touch: true, counter_cache: true
end
User < ApplicationRecord
has_many :job_applications, inverse_of: :user, dependent: :destroy
end
Any idea why this would be happening?
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 da JSONAPI::Resource#preload_include_fragments e verifica come pluck_attrs seleziona la propria Arel::Table durante l’include JobApplication/User descritto. Riproduci il problema con la configurazione dell’associazione indicata nel report, quindi verifica che l’inclusione di user usi user_id 68 anziché Account ID 11 e non generi più l’errore di chiave non trovata.
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