Skip to content

Commit b81ec1c

Browse files
xanonidweiznich
authored andcommitted
Fix print-schema crash with mariadb client library
In certain Linux distributions, the MariaDB client library incorrectly returns a length of 0 for NULL Decimal fields, rather than utilizing the is_null flag as expected. diesel print-schema fails in this case with "Failed to execute a database query: Error deserializing field 'character_maximum_length': could not convert slice to array". This patch introduces an additional check to handle this specific case.
1 parent 2da8809 commit b81ec1c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

diesel/src/mysql/connection/bind.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ impl BindData {
410410
} else {
411411
let data = self.bytes?;
412412
let tpe = (self.tpe, self.flags).into();
413+
// On some distributions, the mariadb client library returns length 0 for NULL fields of type DECIMAL
414+
// instead of using is_null for unknown reasons
415+
if self.tpe == self::ffi::enum_field_types::MYSQL_TYPE_LONGLONG && self.length == 0 {
416+
return None;
417+
}
418+
413419
let slice = unsafe {
414420
// We know that this points to a slice and the pointer is not null at this
415421
// location

0 commit comments

Comments
 (0)