luckyframework / luckyframework/avram
Should preloads on existing models do nothing if association already exists?
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
If a user belongs to an org and I am passed a user object in my method but need to access the org so I call `orged_user = UserQuery.preload_org(user)` should that re-fetch the organization if that association was preloaded somewhere else? It currently does.
If we make the change to not re-query we'd have to add a way to force it so that we can do preloads with conditions and make sure it runs. I'd also want to look into how Ecto does it to see if they've considered it.
Contributor guide
Research direction
Start by tracing the UserQuery.preload_org(user) entry point and how it handles an association that is already loaded. Compare the behavior with Ecto as suggested, then define whether existing associations should avoid a query while conditional or forced preloads still run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100