Ensure it is possible to order entries by integer, float or date fields#154
Conversation
PR Summary
|
|
This solution is MySQL specific, so that would mean it's not something we could incorporate into a release. Im very open to finding an alternative way to sort this, especially if we can apply it to other column types too. By the way, as a work around, you could make a migration to create a stored/generated field in MySQL with the value of the column and the data type you want. MySQL is smart enough to use that column for performance reasons even when you use data->xxx. |
|
What do you mean by this solution being MySQL specific? This solutions applies to PostgreSQL and SQLite too, or am I missing something? |
|
Sorry, wrong way round. I should have said it doesn't work in MySQL. In MySQL the syntax would need to be SQLite seems to use the same syntax: https://www.sqlite.org/json1.html#jptr Am I missing something? |
|
Oh, I see the problem now. And I am with you that there should probably no MySQL/Postgres/SQLite specific code included in the query builder. One solution that came across my mind: We could extend the grammars and add a method |
|
It's a hard one to solve while not making it specific to a certain database engine. |
|
@helloiamlukas ok, heres a change of approach to use CAST(x as y) where available. Let me know your thoughts on this. |
|
Looking good to me, thank you :) One more thing we should maybe consider: Text fieldtypes can have a |
|
I think I'm happy enough (for now) to say that you have to use one of the explicit field types... we can always revisit that later down the road if that needs to change. Thanks for your help! |
orderByorderBy any integer, float or date fields
orderBy any integer, float or date fields
fixes #153