CodeDredd / pinia-orm

The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
https://pinia-orm.codedredd.de/
MIT License
444 stars 38 forks source link

Casts are not properly called on repository update #1864

Closed Graphmaxer closed 3 months ago

Graphmaxer commented 3 months ago

Environment

No response

Reproduction

On https://github.com/Graphmaxer/pinia-orm/tree/fix/cast-on-update with test feature/casts/custom_casts

Describe the bug

When updating an existing model inside a repo via save the cast is not properly called

Additional context

No response

Logs

No response

Graphmaxer commented 3 months ago

This looks like the issue is coming from this change https://github.com/Codedredd/pinia-orm/commit/4ecf93f43b2dcfb98864f7c791a3d70c8be58a99#diff-400250a2f26ef8d1fdaaa2a3757bfdf1dd8fda2c402d89c0670a7d7c110b260bL840, the new data record is not hydrated when updating an existing entry

CodeDredd commented 3 months ago

@Graphmaxer This was somehow also more a feature than a bug. I didn't exspect custom classes as values with their own serialzer.

Graphmaxer commented 3 months ago

Thanks you a lot :+1: We got this use case in our migration from vue/vuex-orm to pinia/pinia-orm. Maybe we should document this feature in the documentation ? :thinking: