Skip to content

Conversation

@jasonvarga
Copy link
Member

This fixes the issue where the new entries query builder augmentation (#5238) wouldn't maintain the order you picked.
i.e. In the control panel you intentionally pick entries in a specific order, and it wouldn't output them in that order. Now it will.

Adds an "ordered" query builder decorator.

It wraps up a query builder with a custom order. If you don't call orderBy on it, it'll apply the custom order when retrieving the items.


In database-land, you could do a raw orderby query, like this:

->whereIn('id', [4, 2, 5])
->orderByRaw("FIELD(id, 4, 2, 5)")

...but we don't support that, and it would be way more effort to do it than this decorator class.

@jasonvarga jasonvarga merged commit 3fe494d into master Mar 1, 2022
@jasonvarga jasonvarga deleted the feature/orderable-query-builder branch March 1, 2022 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants