statamic-rad-pack / runway

Eloquently manage your database models in Statamic.
https://statamic.com/runway
MIT License
107 stars 43 forks source link

Can't save HasMany model in stack #546

Closed edalzell closed 2 weeks ago

edalzell commented 2 weeks ago

Description

I have a model Orphan, with a has_many updates. That OrphanUpdate resource/model has a belongs_to field pointing to Orphan.

When I open the update in the Orphan via the stack CleanShot 2024-07-03 at 15 28 39@2x

And try to save, I get an error due to this SQL:

update
  `orphan_updates`
set
  `orphan_id` = '{\"id\":683,\"last_name\":\"Asif\",\"title\":\"Asif\",\"edit_url\":\"https:\\/\\/zakat.test\\/cp\\/runway\\/orphan\\/683\",\"age\":0}',
  `text` = 'yo yo, updated',
  `orphan_updates`.`updated_at` = '2024-07-03 15:25:36'
where
  `id` = 4504

It's due to this code: CleanShot 2024-07-03 at 15 29 50@2x

Steps to reproduce

  1. Have main resource/model
  2. Have has_many/belongs_to field
  3. create new child via stack
  4. update child via stack
  5. save

Environment

Environment Application Name: Zakat Foundation of America Laravel Version: 11.14.0 PHP Version: 8.3.8 Composer Version: 2.7.6 Environment: local Debug Mode: ENABLED URL: zakat.test Maintenance Mode: OFF Timezone: America/Los_Angeles Locale: en

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

Drivers Broadcasting: null Cache: file Database: mysql Logs: stack / daily Mail: smtp Queue: sync Session: file

Livewire Livewire: v3.5.2

Statamic Addons: 13 Sites: 3 (zakat.org (EN), zakat.org (AR), zfinstitute.com (ZFI)) Stache Watcher: Disabled Static Caching: Disabled Version: 5.12.0 PRO

Statamic Addons aryehraber/statamic-captcha: 1.12.0 edalzell/forma: 3.0.1 jacksleight/statamic-bard-mutator: 2.3.1 jacksleight/statamic-distill: 0.7.2 jonassiewertsen/statamic-livewire: 3.6.0 statamic-rad-pack/runway: 7.5.2 statamic/seo-pro: 6.0.3 transformstudios/events: 5.4.3 transformstudios/front: 3.0.1 transformstudios/github: dev-main transformstudios/neon: dev-main transformstudios/review: 5.0 transformstudios/simple: 5.1.9

edalzell commented 2 weeks ago

FYI, this is preventing our largest customer from using the system, if I can help debug/fix in anyway, please let me know.

TheBnl commented 2 weeks ago

This is similar to an issue I opened (got moved to discussions) -> https://github.com/statamic-rad-pack/runway/discussions/544

duncanmcclean commented 2 weeks ago

I'll take a look today 👍