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

Deserialization does not support newtypes #1778

Open
sjunepark opened this issue Oct 5, 2024 · 0 comments
Open

Deserialization does not support newtypes #1778

sjunepark opened this issue Oct 5, 2024 · 0 comments

Comments

@sjunepark
Copy link

sjunepark commented Oct 5, 2024

Issue corresponding to a PR #1779. (Relevant tests are included in the PR)
In the current version, newtype fields aren't able to be deserialized as seen below.

#[cfg(feature = "serde")]
#[tokio::test]
async fn deserialize_row() {

// ... ommitted

    #[derive(Deserialize, Debug)]
    struct Data {
        id: i64,
        name: String,
        score: f64,
        data: Vec<u8>,
        age: Option<i64>,
        none: Option<()>,
        status: Status,
        wrapper: Wrapper,
        newtype: NewType,
    }

    #[derive(Deserialize, Debug, PartialEq)]
    struct NewType(String);

// ... ommitted

    let data: Data = libsql::de::from_row(&row).unwrap();

// ... ommitted

    // Fails !!!
    assert_eq!(data.newtype, NewType("Newtype".to_string())); 
}   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant