Repository navigation
Conversation
|
Come to think of it, the name of the new config key is pretty nondescript. Very open to suggestions here :) |
…umns Without intl, register a case-insensitive natural sort collation instead of NOCASE so the order matches Comparator::strings(). Don't collate mapped entry data columns that don't have text affinity, so they keep using their indexes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for this, it's a really nice PR. I've pushed a commit (3e39e2f) with two changes:
I added tests for both. A few other thoughts, none of them blocking:
|
Issue
The Eloquent driver sorts text byte-by-byte. Flat files sort text alphabetically for the site's language. So the same content comes back in a different order depending on the driver. Capitals before lowercase, umlauts at the end and
10before2etc. It's most noticeable when sorting assets by filename or entries by title.Solution
A new opt-in config: when enabled, sorting by a text field gives the same order as flat files. The driver mimics Statamic's
Comparator. Number and date fields still sort as numbers and dates. Open to better names for the config.2before10,IMG_3beforeIMG_20)Off by default
It does make sorting slower. SQLite doesn't have alphabetical sorting built in, so the comparison is done by PHP. When not using an index (e.g. sorting entries by title), it is around twice as slow, so I'd suggest making this opt-in to allow performance-minded folks to keep their Eloquent speed-up :)
Benchmarks
Drive-by fixes
TypeError(AssetQueryBuilder::getJsonCasts()returned an array instead of a collection)orderByDesc()andreorder()now apply the same number/date casting asorderBy()Limitations
intlextensionintl, sorting is only made case-insensitive