Skip to content

Deserialization does not support newtypes #1778

@sjunepark

Description

@sjunepark

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())); 
}   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions