prisma / tiberius

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

fix: correctly decode null integers & floats #209

Closed Weakky closed 2 years ago

Weakky commented 2 years ago

Overview

Related to https://github.com/prisma/prisma/issues/12796 and https://github.com/prisma/prisma/issues/12798

There were existing tests reading nullable integers, but those tests were only trying to convert the ColumnData to a rust primitive type and assert that primitive type. However, because of those FromSql implementations 👇 which enable converting a ColumnData::U8 and ColumnData::I32 to an Option<i64>, tests were passing.

I left those FromSql implementations since I'm not sure what they're used for atm.

https://github.com/prisma/tiberius/blob/e88859099fc38e61dd01990567a928872efb08ad/src/from_sql.rs#L64

Tests now also ensure that all integers + floats are decoded as the proper ColumnData in the case of null values.