From 794ae38ae1df182b8130e7f096d6f004b741a042 Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Wed, 18 Oct 2023 08:00:42 +0200 Subject: [PATCH] binding numeric column with MSSQL --- odbc-api/tests/integration.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/odbc-api/tests/integration.rs b/odbc-api/tests/integration.rs index b1681f13..3cac2494 100644 --- a/odbc-api/tests/integration.rs +++ b/odbc-api/tests/integration.rs @@ -4073,9 +4073,9 @@ fn fetch_decimal_as_numeric_struct_using_get_data(profile: &Profile) { assert_eq!(0, target.0.val[2]); } -// #[test_case(MSSQL; "Microsoft SQL Server")] +#[test_case(MSSQL; "Microsoft SQL Server")] #[test_case(MARIADB; "Maria DB")] -// #[test_case(SQLITE_3; "SQLite 3")] +// #[test_case(SQLITE_3; "SQLite 3")] Always filled with zero #[test_case(POSTGRES; "PostgreSQL")] fn fetch_decimal_as_numeric_struct_using_bind_col(profile: &Profile) { // Given a cursor over a result set with a decimal in its first column @@ -4121,8 +4121,17 @@ fn fetch_decimal_as_numeric_struct_using_bind_col(profile: &Profile) { ); let _ = odbc_sys::SQLSetDescField(hdesc, 1, odbc_sys::Desc::Precision, 5 as Pointer, 0); let _ = odbc_sys::SQLSetDescField(hdesc, 1, odbc_sys::Desc::Scale, 3 as Pointer, 0); - - stmt.bind_col(1, &mut target); + // Setting the dataptr directly on the ARD is required to make it work for MSSQL which does + // seem to set the wrong pointer if just using bind col. Postgres and MariaDB would work as + // intended with bind_col. + // stmt.bind_col(1, &mut target); + let _ = odbc_sys::SQLSetDescField( + hdesc, + 1, + odbc_sys::Desc::DataPtr, + &mut target as *mut Numeric as Pointer, + 0, + ); stmt.fetch();