luckyframework / luckyframework/avram
Ordering fails for preload queries
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
In this use case, `tracks` ordering does not work:
```
playlists = PlaylistQuery.new
.preload_cover(
StashQuery.new.preload_icon.preload_cover.preload_archive)
.preload_tracks(
StashQuery.new.preload_icon.preload_cover.preload_archive.ordering.asc_order)
.preload_interviews(
StashQuery.new.preload_icon.preload_cover.preload_archive.ordering.asc_order)
.published(true)
.ordering
.asc_order
```
```
class Playlist < BaseModel
table do
column lang : Int32
column title : String
column ordering : Int32
column description : String
column published : Bool
belongs_to cover : Stash?
has_many playlists_tracks : PlaylistsTracks
has_many tracks : Stash, through: [:playlists_tracks, :stash]
has_many playlists_interviews : PlaylistsInterviews
has_many interviews : Stash, through: [:playlists_interviews, :stash]
belongs_to modified_by : User
end
end
```
```
class Stash < BaseModel
table do
column lang : Int32
column ordering : Int32
column title : String
column slug : String
column author : String?
belongs_to icon : Stash?
belongs_to cover : Stash?
has_many playlists_tracks : PlaylistsTracks
has_many playlists_interviews : PlaylistsInterviews
belongs_to modified_by : User
end
end
```
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
Start by reproducing the shown PlaylistQuery with preload_tracks and its nested StashQuery ordering.asc_order. Inspect how preload_tracks applies the nested query and compare it with preload_interviews; done means the preloaded tracks are returned in ascending ordering.
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
- Needs clarification
- Newbie friendliness
- 35/100