libsql icon indicating copy to clipboard operation
libsql copied to clipboard

Add `enum` deserialization for sqlite Value

Open sveltespot opened this issue 1 year ago • 2 comments

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.

sveltespot avatar Apr 09 '24 15:04 sveltespot

@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 avatar Apr 24 '24 15:04 sveltespot

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

aminya avatar May 06 '24 19:05 aminya