-
Couldn't load subscription status.
- Fork 92
Preserve order from CP when saving entries #57
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
|
Update: I've tapped into laravel core builder methods to cast the order as a real field which seems to do the trick. |
|
If you can supply a sample repository with clear steps to reproduce the issue then I can look into it further.
… On 16 Sep 2022, at 15:28, Enes Polat ***@***.***> wrote:
<https://user-images.githubusercontent.com/21336979/190662690-188aa983-f89c-4e1b-b746-115c65c60558.png>Hi , i tried this pr again and i have time format issue while reordering , is it something to do with my mysql configuration ?
—
Reply to this email directly, view it on GitHub <#57 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAMVOZ2NLSC3OLZM5JMEPLV6R72RANCNFSM6AAAAAAQFE2MXA>.
You are receiving this because you authored the thread.
|
|
That shouldnt be necessary as `updated_at` should come from the laravel model timestamps.
|
|
@enespolat24 can you create a sample repository so I can look into this further? |
|
hi , sorry for the latency |
|
@jasonvarga this is good to merge from our testing and the feedback from others |
|
@ryanmitchell I tested this with one of my live projects. We use mariaDb instead of mysql. Can we use |
|
What’s the support for that on SQLite, Postgres and MySQL?
|
|
I checked their docs. they all support |
|
Ok. I ran some quick tests and it seems ok to switch to that.
… On 28 Sep 2022, at 16:02, Enes Polat ***@***.***> wrote:
I checked their docs. they all support DOUBLE PRECISION but in the Postgres there's a storage size difference. REAL uses 4 byte but DOUBLE PRECISION uses 8 byte
—
Reply to this email directly, view it on GitHub <#57 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAMVO66USZ3QH2T5QUWKYLWARMY3ANCNFSM6AAAAAAQFE2MXA>.
You are receiving this because you were mentioned.
|
|
@jasonvarga would be great to get this merged as ordering isn't working in the CP at the moment. |
|
@enespolat24 Does this PR fix your issue? Last you said on #43 was that you're still having issues. |
|
@ryanmitchell What's the reason for using the I'm using MariaDB 10.5.8 and it doesn't seem to like that syntax. I get the following error when I visit the reorder entries screen in the CP. select
*
from
`entries`
where
`collection` = 'more_pages'
order by
CAST(
json_unquote(json_extract(`data`, '$."order"')) AS DOUBLE PRECISION
) ASC
limit
50 offset 0 |
|
@jasonvarga works like a charm with mysql but i tried this with our Mariadb 10.6.3 and got same error as you do. the walk around i did was changing |
|
Yeah I was trying to avoid adding a column but I guess in hindsight it’s just making things more complicated. I’ll refactor it to use a nullable order column
|
|
Two things:
|
|
Order is a reserved word in some db engines. I’ve always avoided using it as a result. Yeah the migrations annoyed me too - I don’t like the approach of publishing then every time but others contributing to the big PR wanted it so I gave in. To me it should automatically publish but I think we are stuck now? |
I would think as long as its quoted appropriately it'll be fine with it being a column name. ie. As for publishing the migrations.... even if you publish the migrations again, it publishes all of them, not just new ones. 🤔 |
|
Ok I’ll change it over later on. Yeah I should have really pushed back on the migrations, I knew it wasn’t the right approach - sorry about that. do we need to do something like the upgrade to logic in core that you use for adding permissions etc? |
|
Thanks. We'll figure out the migration side of it from here. Leave it with us. Much appreciated! |
|
Sorry that ive left you with a mess to clean up! |
32c8e51 to
cd2a5a4
Compare


This goes some of the way to resolving issue #43 in that it preserves the order, however if we're using incrementing IDs then ordering will fail once IDs hit double digits as it will treat it as string ordering rather than numeric ordering (so 1, 10, 2, 3 etc).
I'm not sure how to resolve this in the JSON field with getting into specific code for specific database types.
The best option might be to make an
ordercolumn in the database for handling this?Edit by Jason:
ordercolumn.