You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An option for serde Serialize/Deserialize of ActiveModel, ActiveValue and Value
Motivation
Possible use cases:
to log db write activities for debugging purposes (the one I am interested in): to better pinpoint bugs and erroneous behavior, I would like to store in a table or file the ActiveModels that generated insert/update/delete operations so that I know exactly with what parameters the model was called with
to have the history of a database for data recovery/reconstruction/integrity: when data are valuable, the ability to start from a snapshot of the Db and simply re-perform some or all of the write operations is handy
to help with the dyn unsafe traits of SeaORM: when you want to construct functions that perform operations on a variety of ActiveModels and Models, the 'impl ActiveModelTrait' is not a solution because it is dyn unsafe. Having the ability to serialize/deserialize the model makes the operation a lot easier
SeaORM offers the option to add serde Serialize/Deserialize for Model, but transforming the ActiveModel into a Model and serializing it loses important information such as Set/Unset/Unchanged status for each field.
Implementation
At a first glance of the source code, the implementation should be easy and straightforward, requiring only some incremental and non-disrupting changes to the code.
I manually copied/pasted some ActiveModel/ActiveValue/Value in my code and it compiled flawlessly, so there is nothing not serde-safe in the ActiveModel/ActiveValue/Value.
It is required only to add a derive Serialize/Deserialize to the template (as Model has) and the logic to implement it
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal
An option for serde Serialize/Deserialize of ActiveModel, ActiveValue and Value
Motivation
Possible use cases:
SeaORM offers the option to add serde Serialize/Deserialize for Model, but transforming the ActiveModel into a Model and serializing it loses important information such as Set/Unset/Unchanged status for each field.
Implementation
At a first glance of the source code, the implementation should be easy and straightforward, requiring only some incremental and non-disrupting changes to the code.
I manually copied/pasted some ActiveModel/ActiveValue/Value in my code and it compiled flawlessly, so there is nothing not serde-safe in the ActiveModel/ActiveValue/Value.
It is required only to add a derive Serialize/Deserialize to the template (as Model has) and the logic to implement it
Beta Was this translation helpful? Give feedback.
All reactions