Fix ordering assets by integers, floats, and date fields#487
Fix ordering assets by integers, floats, and date fields#487duncanmcclean merged 17 commits into4.xfrom
Conversation
There was a problem hiding this comment.
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.