luckyframework / luckyframework/avram
preload doesn't set the reverse association
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I have a URLPath model which belongs_to my Language model. Language has_one URLPath. I load both objects using URLPathQuery.new.path(path).preload_language.first
In the two resulting records, url_path.language is valid, but url_path.language.url_path is nil.
Preloading should set both sides of the association.
If I do something like this: URLPathQuery.new.path(path).preload_language.preload_url_path.first
then I get two copies of the URLPath record, and the url_path.language.url_path.language is nil.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the URLPath and Language models using URLPathQuery.new.path(path).preload_language.first, then inspect how the preload association is populated. Compare the resulting url_path.language and url_path.language.url_path objects, including the chained preload case; done means both sides reference the expected association without duplicate records.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100