-
Notifications
You must be signed in to change notification settings - Fork 91
Fix ordering assets by integers, floats, and date fields #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, and is the right solution to fix the ordering issue. I think it should be merged to solve that immediate need.
However, thinking a bit further ahead to how we would solve issues like this one I wonder if we should be moving this logic to within function column()
in the base eloquent query builder class.
take for example: https://github.com/statamic/cms/blob/d1e056b3be05d2df0bcbd92a818d11b08eff9e8c/src/Query/EloquentQueryBuilder.php#L185C32-L185C36
if this->column() returned the cast, we could do a ->whereRaw() based on it. Similarly for the other where clauses 🤔
It's required by the EloquentQueryBuilder in core.
Interesting! We could do the same sorta thing in I don't know if we want to change what Happy to chat about it offline 🙂 |
This pull request aims to fix an issue when ordering assets by integers, floats, dates, where the Eloquent Driver would consider the ints/floats/dates as strings, and order alphabetically, rather than numerically.
This PR takes a similar approach to #154 which fixed the same issue for entries, but I've refactored the logic to make it slightly tidier.
Before:
After:
Fixes #420.
Replaces #486.