-
-
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
Diesel_derives only considers flags comming from one of multiple #[diesel(…)]
atttributes
#2584
Comments
As the documentation mentions here Closed as this is not an issue or feature request. Use our gitter channel or our forum to ask for support or tho get answers to your questions. |
@weiznich |
@dawid-nowak I that case I would appreciate getting a complete self contained example where you think something does not work as expected including the exact version you've used. Otherwise I do not see how this would be actionable at all. |
@weiznich
expected is that expected is that on read User should be as follows schema:
Cargo.toml
exact version |
So I had a short look at this. Seems like we don't handle the case that some attribute occurs more than once well. If you change your code to the following everything will work fine: #[derive(Identifiable, Queryable, PartialEq, Debug, Serialize, Deserialize, Insertable)]
#[table_name = "users"]
pub struct User {
pub id: i32,
#[diesel(serialize_as = "SensitiveStringSerializer", deserialize_as = "SensitiveStringDeserializer")]
pub s1: String,
#[diesel(deserialize_as = "SensitiveStringDeserializer", serialize_as = "SensitiveStringSerializer")]
pub s2: String,
#[diesel(serialize_as = "SensitiveStringSerializer")]
pub s3: String,
#[diesel(deserialize_as = "SensitiveStringDeserializer")]
pub s4: String,
} (Note that I've changed just fields 1 and 2 to have the annotations in a combined attribute instead of having separate ones.) Having said that: This is definitively something I would consider as bug, therefore I will reopen the issue. For the next time: Just fill out the issue template as it asks for most of the information required to reproduce nearly all bugs. For anyone willing to look into fixing this: We would need change this function to not only return the first attribute with matching name, but all. That implies that we need to find a way to merge flags provided by multiple attributes + decide how to handle duplicated flags there. |
#[diesel(…)]
atttributes
now we are talking :) cheers |
I actually had this fixed in my branch of moving all attributes to |
That branch is blocked on #2557 which I will finish off first. |
Is it supported at the moment to have 'serialize_as' and 'deserialize_as' on the single field in the sturcture as shown below?
The text was updated successfully, but these errors were encountered: