Skip to content
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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ISibboI
Copy link
Contributor

@ISibboI ISibboI commented Oct 20, 2023

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.

@ISibboI ISibboI marked this pull request as ready for review October 20, 2023 10:43
@weiznich weiznich requested a review from a team October 20, 2023 11:26
Copy link

@shellcodesniper shellcodesniper left a 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..?

@shellcodesniper shellcodesniper requested a review from a team October 25, 2023 00:56
@Ten0
Copy link
Member

Ten0 commented Oct 25, 2023

i think it can provide support enums to mysql

Isn't there some form of support for this via https://crates.io/crates/diesel-derive-enum ?

Copy link
Member

@weiznich weiznich left a 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) => {
Copy link
Member

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.

diesel_derives/tests/insertable.rs Show resolved Hide resolved
diesel_derives/tests/insertable.rs Show resolved Hide resolved
@pksunkara
Copy link
Member

pksunkara commented Mar 28, 2024

The code looks okay to me.

  • Need tests for AsChangeset logic
  • Need tests for deserialize_fn
  • Need to add the newly added attributes to UnknownAttribute error
  • Need UI tests for all the errors added in this PR
  • Need documentation for the new attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants