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

Bug: Serialization error when using nested structs with a record id. #4844

Open
2 tasks done
Quat3rnion opened this issue Sep 19, 2024 · 3 comments · May be fixed by serde-rs/serde#2836
Open
2 tasks done

Bug: Serialization error when using nested structs with a record id. #4844

Quat3rnion opened this issue Sep 19, 2024 · 3 comments · May be fixed by serde-rs/serde#2836
Labels
sdk-issue Issues with the Rust SDK specifically topic:rust This is related to the Rust embedded library

Comments

@Quat3rnion
Copy link

Describe the bug

Using nested structs, where RecordId is anywhere except the top level, results in a serialization error: untagged or internally tagged enums do not support enum input

Steps to reproduce

Using the following structs, attempt to client.create::<Option<UserEntity>>("table")

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserEntity {
    #[serde(flatten)]
    inner: User,
    pub password_hash: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct User {
    pub id: RecordId,
    #[serde(flatten)]
    inner: UserData,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserData {
    pub name: String,
}

Expected behaviour

No error, as it worked in 1.5.5

SurrealDB version

2.0.1 for linux on x86_64

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Quat3rnion Quat3rnion added bug Something isn't working triage This issue is new labels Sep 19, 2024
@DelSkayn DelSkayn changed the title Bug: Bug: Serialization error when using nested structs with a record id. Sep 20, 2024
@rynoV
Copy link

rynoV commented Sep 21, 2024

I'm also running into this.

I believe this is the error source
https://github.com/serde-rs/serde/blob/4487cb26c7f86210c25aeb9d04add9a2e51ad74d/serde/src/private/de.rs#L533

There's some discussion here about a similar looking issue (in particular the last comment looks useful)
dtolnay/serde-yaml#344

Hopefully this helps whoever looks into this

@tobiemh tobiemh added topic:rust This is related to the Rust embedded library sdk-issue Issues with the Rust SDK specifically and removed bug Something isn't working triage This issue is new labels Sep 24, 2024
@raxosiris
Copy link

Also running into the same

@frederik-uni frederik-uni linked a pull request Oct 18, 2024 that will close this issue
@frederik-uni
Copy link

frederik-uni commented Oct 19, 2024

this patch can be used until serde is updated

[patch.crates-io]
serde = { git = "https://github.com/frederik-uni/serde" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk-issue Issues with the Rust SDK specifically topic:rust This is related to the Rust embedded library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants