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

Entry's form is not filled with data column values when editing #108

Closed piljac1 closed 1 year ago

piljac1 commented 1 year ago

Environment

Laravel Version: 9.48.0 PHP Version: 8.1.12 Composer Version: 2.1.6 Database: MySql 8.0.31 Statamic Version: 3.3.65 PRO

The issue

After following the "Storing Entries in a Database" docs (apart from the fact I use an auto-increment ID), I encountered an issue where creating a new entry (a Page in my case) would store everything accordingly in the entries table, but when editing the newly created entry, nothing that is stored in the data column was filled (i.e. Title).

After debugging, I found out that when selectableColumns is called, the data column is not included in the fetched columns. If I hardcode return ['*']; without anything else in that method, it fills the form properly. Of course, it is not a proper fix, but it might be a good place to start debugging further.

Reproduction repo

P.S. My "hotfix" is applied in this repo, so if you want to see the actual bug, search for selectableColumns method in app/Eloquent/Entries/EntryQueryBuilder.php and comment it.

https://github.com/piljac1/statamic-eloquent-issues

ryanmitchell commented 1 year ago

Can you close this?