-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add serialize_fn
attribute to Insertable
derive macro
#3837
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it can provide support enums to mysql !
souunds good
how about other reviewers..?
Isn't there some form of support for this via https://crates.io/crates/diesel-derive-enum ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this PR 👍 The implementation itself looks fine for me and I'm open this feature.
The PR is currently missing:
- Some more tests
- Documentation for the new feature
Additionally I would like to keep the functionality for serialize
and deserialize
similar, that means we should add an
- Implementation for
AsChangeset
to keep that attribute compatible there as well - A corresponding implementation for deserializing to keep the functionality somewhat symmetrical
return Err(syn::Error::new( | ||
*attribute_span, | ||
"`#[diesel(embed)]` cannot be combined with `#[diesel(serialize_as)]`", | ||
)); | ||
} | ||
(None, Some(AttributeSpanWrapper { attribute_span, .. }), true) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to have a compile_fail
test for this cases.
The code looks okay to me.
|
See #3836.
I would be happy to get some feedback about the implementation. I would write documentation if you are fine with the implementation as it is. I can also add more tests if needed.