tursodatabase / tursodatabase/libsql
Deserialization does not support newtypes
Open
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
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()));
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing PR #1779 and its relevant tests, especially the deserialize_row example using libsql:🇩🇪:from_row. Confirm how NewType(String) is handled during deserialization. Done means the provided assertion for data.newtype succeeds and the relevant tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100