-
Notifications
You must be signed in to change notification settings - Fork 74
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
Sorting counts null as the string 'null' #217
Comments
So for example if you If you could give the result of |
Sorry, this is through the API with a query parameter like
|
It probably wont make any difference, but can you update eloquent-driver to 2.10.0 just to be sure you're on the latest version? I can see its data held in the json field so that gives me something to work with. |
Yes, it's actually a stored computed field in the JSON, in this case. Updating to 2.10 did not help, unfortunately. |
I've taken a quick look but I'm not sure theres a whole lot we can do here as we're deferring to the underlying database engine for sorting, and MySQL is choosing to treat it as an 'n' rather than blank. Obviously if youre using a computed field you could blank it rather than null, but that doesn't help when its not a computed field. Open to any suggestions. |
MySQL normally puts null first if you're sorting strings in ascending order, so that doesn't sound like it's MySQL doing it. Is this JSON field related? Is there a sort happening on the text value somewhere? |
Yeah it's when sorting on the json field. I can replicate the same sort order with a database query. |
It looks like this is actually a known issue. https://bugs.mysql.com/bug.php?id=85755 |
I guess we can close this, since it's a MySQL issue and not with this driver. Thanks for your help! |
I think our alternative to this is to create a new column in the entries table which can hold this value so that we can sort on there. Is that supported by this package? |
Putting in a new column in the entries table would make that column for all entry types, so it would be even better if we could have a dedicated table for this one collection. I'd be happy to write the migrations to have a separate table for this collection if that is possible. Is that possible to do, or must all entries be in the same table? |
It's not possible to use a seperate table. I'd suggest taking a look at Runway if you want that. |
Yeah, I checked that out, but unfortunately it doesn't support the content API, which we make significant use of. |
Maybe make your own api controller for that resource that extends Statamic's API controller? Looking at the asset controller it seems pretty straight forward? |
@Smef Keep an eye on statamic-rad-pack/runway#356 |
Thanks! |
When sorting on a field with null values,
null
values are treated as the string"null"
and fall in between words starting with the letter 'm' and 'p'. I've changed from the eloquent driver to the file driver and found that the file driver does not have this issue.The text was updated successfully, but these errors were encountered: