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

Add enum deserialization for sqlite Value #1294

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sveltespot
Copy link

Currently, if a sql row read needs to be deserialized into a struct, and the struct has one of the fields as a Rust enum type, then the deserialization fails. For example:

#[derive(Deserialize)]
struct MyRow {
  id: i32,
  status: Status
}

#[derive(Deserialize)]
enum Status {
  Pass,
  Fail
}

The deserialization of a row: 1, 'Pass' will fail.

This commit adds the ability to deserialize a RowValue into an Enum type.

Currently, if a sql row read needs to be deserialized into a
struct, and the struct has one of the fields as a Rust enum
type, then the deserialization fails. For example:

```rust
struct MyRow {
  id: i32,
  status: Status
}

enum Status {
  Pass,
  Fail
}

```
The deserialization of a row: `1, 'Pass'` will fail.

This commit adds the ability to deserialize a RowValue into
an Enum type.
@sveltespot
Copy link
Author

@haaawk @LucioFranco Apologies for tagging. Could you help review and possibly merge this PR. It adds deserialization of a sqlite row into a struct that contains one of the fields as a unit Rust enum, which currently fails.

@sveltespot sveltespot closed this May 2, 2024
@aminya
Copy link

aminya commented May 6, 2024

@sveltespot Why did you close this PR? Could you reopen it so it is not lost?

@sveltespot sveltespot reopened this May 7, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants