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
New type enables usage of basic wrapper types and JSON support.
However, there are some cases where database columns can be better represented by structs. In addition, (de-)serializing using structs has the advantage of being able to fail early. A good example is the FromJsonQueryResult derive, where I can kind of shift the deserialization error to sea-orm.
I think it might be best explained using serde:
The DeriveValueType macro behaves the same as #[serde(transparent)] ,
Serde also has try_from. Sea-orm could first read as the respective database type and then use try_from to fallibly convert to the target type. The same applies in the reverse direction.
This can be implemented manually already, but requires 4 traits as specified in the docs, which is a lot of boilerplate.
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
-
New type enables usage of basic wrapper types and JSON support.
However, there are some cases where database columns can be better represented by structs. In addition, (de-)serializing using structs has the advantage of being able to fail early. A good example is the
FromJsonQueryResult
derive, where I can kind of shift the deserialization error to sea-orm.I think it might be best explained using serde:
The
DeriveValueType
macro behaves the same as#[serde(transparent)]
,Serde also has try_from. Sea-orm could first read as the respective database type and then use try_from to fallibly convert to the target type. The same applies in the reverse direction.
This can be implemented manually already, but requires 4 traits as specified in the docs, which is a lot of boilerplate.
Beta Was this translation helpful? Give feedback.
All reactions