nooberfsh / prusto

A presto/trino client library written in rust.
MIT License
37 stars 23 forks source link

Adds visiting unit type for optional data #38

Closed choubacha closed 7 months ago

choubacha commented 7 months ago

When field is optional the QueryResult will end up visiting a unit type instead of an option type (none or some). This is part of the default implementation of serde (as opposed to serde_json). For some reason, the nesting of the field data_set within it seems to trigger a fallback to the original serde code and not the serde_json code.

To reproduce this, an optional field is added to the query result finished test. This value is then set to null in the test data and loaded in. Specifying that it visits a unit corrects the behavior by mapping it to a None value.

Fixes #37

choubacha commented 7 months ago

An important note is that I haven't been able to determine why the error that was raised ended up getting swallowed somewhere in the code.

nooberfsh commented 7 months ago

Thanks for the bug reporting and quickly fixing it, I have to admit that I have forgot most of the serde mechanism and I will pick it up laterrr, but I think your fix is reasonable.

Regarding to the error swallow, It may be related to https://github.com/serde-rs/serde/issues/1880, but I could be wrong.