statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 73 forks source link

Unable to reorder collection #150

Closed jorisvan-ons closed 11 months ago

jorisvan-ons commented 1 year ago

Reordering seems bugged. The values are coming through in the correct order when inspecting the $reorderedEntries->values()->all() in the ReorderEntriesController.

However, the table is reloaded and the values are back in the old order again. The database 'order' columns to not seem to be updated. Manually changing the order columns does work.

ryanmitchell commented 1 year ago

Can you run php please support:details and paste the result here?

jorisvan-ons commented 1 year ago

`Environment Application Name: CENSORED Laravel Version: 9.52.6 PHP Version: 8.2.3 Composer Version: 2.5.1 Environment: local Debug Mode: ENABLED URL: CENSORED Maintenance Mode: OFF

Cache Config: CACHED Events: NOT CACHED Routes: CACHED Views: CACHED

Drivers Broadcasting: log Cache: statamic Database: mysql Logs: stack / single Mail: smtp Queue: sync Session: file

Statamic Addons: 4 Antlers: runtime Stache Watcher: Enabled Static Caching: Disabled Version: 3.4.7 PRO

Statamic Addons doublethreedigital/runway: 4.2.4 mitydigital/iconamic: 1.1.4 octoper/statamic-blade-components: 2.0.0 statamic/eloquent-driver: 1.2.0`

ryanmitchell commented 1 year ago

Thanks. Nothing is jumping out at me there. Is your collection dated as well as order able? I wonder if this fix might help: https://github.com/statamic/eloquent-driver/pull/138

jorisvan-ons commented 1 year ago

No, the collection is not dated. The date fields are all set to NULL in the database.

jorisvan-ons commented 1 year ago

Here is the yaml file of the collection

title: Products
template: products/show
layout: layouts/app
revisions: false
route: '/products/{slug}'
sort_dir: asc
date_behavior:
  past: public
  future: private
preview_targets:
  -
    label: Entry
    url: '{permalink}'
structure:
  root: false
  max_depth: 1
ryanmitchell commented 1 year ago

Thanks for the blueprint, I was able to replicate your issue.

However, when I apply the code change in the PR i previously linked: https://github.com/statamic/eloquent-driver/pull/138 then this issue goes away for me.

jorisvan-ons commented 1 year ago

Thanks for the suggestion. However, applying the code change does not fix the issue for me. The class/method does not seem to be used when I reorder or even try to create a new entry?

ryanmitchell commented 1 year ago

Are you able to supply access to a sample repository that shows the issue? I’m unfortunately not able to recreate the issue at this point.

ryanmitchell commented 1 year ago

@jorisvan-ons any further update on this? If you have upgraded to 2.1.0 does the issue still exist?

jorisvan-ons commented 1 year ago

It seems to be fixed in our new projects. Will update old projects to make sure it works with 2.1.0, thanks for your help!

jorisvan-ons commented 1 year ago

Still not working on 2.1 and 2.2.

ryanmitchell commented 1 year ago

Have you tried re-saving the collection config? Or removing the sort field key from the database? There were some issues with sort fields being saved when they shouldn’t.

ryanmitchell commented 11 months ago

Closing due to inactivity.