prisma / tiberius

TDS 7.2+ (Microsoft SQL Server) driver for Rust
Apache License 2.0
325 stars 121 forks source link

FromSql for f32 and f64 for Rust's Optionals on floats #250

Closed TheRustifyer closed 2 years ago

TheRustifyer commented 2 years ago

I am opening this PR because when I work with Rust and tiberius, and I have some Option<f32> and Option<f64>, row.get() produces an Result::unwrap() on a None value.

I am not proud of the purposed solution, as is just a temporal fix. I would like that the dev team could take it as provisional, review my code and purpose a solution over this initial patch.

TheRustifyer commented 2 years ago

Please, if possible, link the PR to this issue.

TheRustifyer commented 2 years ago

...

pimeys commented 2 years ago

Ok, I understand now where this is happening. If a resulting row has enough nulls, SQL Server returns it as a packed row (NBC). It gives us a bitmap that tells the null columns, and we have to react accordingly. There's already a test that triggers this behavior, I will add another one that triggers the bug.

pimeys commented 2 years ago

Closing in favor of https://github.com/prisma/tiberius/pull/253