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 74 forks source link

use created_at column for submission sorting #316

Closed SylvesterDamgaard closed 3 months ago

SylvesterDamgaard commented 3 months ago

Submissions are not sortable due to this query which expects the date to be in the data. This issue is a regression from https://github.com/statamic/eloquent-driver/pull/306 where the date field is grabbed from the created_at column instead.

Result is that old submissions are sortable due to having a date property in data, but new entries do not.

Current query. select * from form_submissions where form = 'tip_os' order by json_unquote(json_extract(data, '$."date"')) desc limit 100 offset 0

This PR changes the query builder to use the created_at column for sorting

The new query will look like this: select * from form_submissions where form = 'tip_os' order by created_at desc limit 100 offset 0