Skip to content

Ordered Query Builder - #5381

Merged
jasonvarga merged 3 commits into
masterfrom
feature/orderable-query-builder
Mar 1, 2022
Merged

Ordered Query Builder#5381
jasonvarga merged 3 commits into
masterfrom
feature/orderable-query-builder

Conversation

@jasonvarga

Copy link
Copy Markdown
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.

1 participant