@@ -320,9 +320,9 @@ SQLRETURN BindParameters(SQLHANDLE hStmt, const py::list& params,
320
320
}
321
321
// TODO: can be moved to python by registering SQL_DATE_STRUCT in pybind
322
322
SQL_DATE_STRUCT* sqlDatePtr = AllocateParamBuffer<SQL_DATE_STRUCT>(paramBuffers);
323
- sqlDatePtr->year = param.attr (" year" ).cast <int >();
324
- sqlDatePtr->month = param.attr (" month" ).cast <int >();
325
- sqlDatePtr->day = param.attr (" day" ).cast <int >();
323
+ sqlDatePtr->year = static_cast <SQLSMALLINT>( param.attr (" year" ).cast <int >() );
324
+ sqlDatePtr->month = static_cast <SQLUSMALLINT>( param.attr (" month" ).cast <int >() );
325
+ sqlDatePtr->day = static_cast <SQLUSMALLINT>( param.attr (" day" ).cast <int >() );
326
326
dataPtr = static_cast <void *>(sqlDatePtr);
327
327
break ;
328
328
}
@@ -333,9 +333,9 @@ SQLRETURN BindParameters(SQLHANDLE hStmt, const py::list& params,
333
333
}
334
334
// TODO: can be moved to python by registering SQL_TIME_STRUCT in pybind
335
335
SQL_TIME_STRUCT* sqlTimePtr = AllocateParamBuffer<SQL_TIME_STRUCT>(paramBuffers);
336
- sqlTimePtr->hour = param.attr (" hour" ).cast <int >();
337
- sqlTimePtr->minute = param.attr (" minute" ).cast <int >();
338
- sqlTimePtr->second = param.attr (" second" ).cast <int >();
336
+ sqlTimePtr->hour = static_cast <SQLUSMALLINT>( param.attr (" hour" ).cast <int >() );
337
+ sqlTimePtr->minute = static_cast <SQLUSMALLINT>( param.attr (" minute" ).cast <int >() );
338
+ sqlTimePtr->second = static_cast <SQLUSMALLINT>( param.attr (" second" ).cast <int >() );
339
339
dataPtr = static_cast <void *>(sqlTimePtr);
340
340
break ;
341
341
}
@@ -346,12 +346,12 @@ SQLRETURN BindParameters(SQLHANDLE hStmt, const py::list& params,
346
346
}
347
347
SQL_TIMESTAMP_STRUCT* sqlTimestampPtr =
348
348
AllocateParamBuffer<SQL_TIMESTAMP_STRUCT>(paramBuffers);
349
- sqlTimestampPtr->year = param.attr (" year" ).cast <int >();
350
- sqlTimestampPtr->month = param.attr (" month" ).cast <int >();
351
- sqlTimestampPtr->day = param.attr (" day" ).cast <int >();
352
- sqlTimestampPtr->hour = param.attr (" hour" ).cast <int >();
353
- sqlTimestampPtr->minute = param.attr (" minute" ).cast <int >();
354
- sqlTimestampPtr->second = param.attr (" second" ).cast <int >();
349
+ sqlTimestampPtr->year = static_cast <SQLSMALLINT>( param.attr (" year" ).cast <int >() );
350
+ sqlTimestampPtr->month = static_cast <SQLUSMALLINT>( param.attr (" month" ).cast <int >() );
351
+ sqlTimestampPtr->day = static_cast <SQLUSMALLINT>( param.attr (" day" ).cast <int >() );
352
+ sqlTimestampPtr->hour = static_cast <SQLUSMALLINT>( param.attr (" hour" ).cast <int >() );
353
+ sqlTimestampPtr->minute = static_cast <SQLUSMALLINT>( param.attr (" minute" ).cast <int >() );
354
+ sqlTimestampPtr->second = static_cast <SQLUSMALLINT>( param.attr (" second" ).cast <int >() );
355
355
// SQL server supports in ns, but python datetime supports in µs
356
356
sqlTimestampPtr->fraction = static_cast <SQLUINTEGER>(
357
357
param.attr (" microsecond" ).cast <int >() * 1000 ); // Convert µs to ns
@@ -395,8 +395,11 @@ SQLRETURN BindParameters(SQLHANDLE hStmt, const py::list& params,
395
395
assert (SQLBindParameter_ptr && SQLGetStmtAttr_ptr && SQLSetDescField_ptr);
396
396
397
397
RETCODE rc = SQLBindParameter_ptr (
398
- hStmt, paramIndex + 1 /* 1-based indexing */ , paramInfo.inputOutputType ,
399
- paramInfo.paramCType , paramInfo.paramSQLType , paramInfo.columnSize ,
398
+ hStmt,
399
+ static_cast <SQLUSMALLINT>(paramIndex + 1 ), /* 1-based indexing */
400
+ static_cast <SQLUSMALLINT>(paramInfo.inputOutputType ),
401
+ static_cast <SQLSMALLINT>(paramInfo.paramCType ),
402
+ static_cast <SQLSMALLINT>(paramInfo.paramSQLType ), paramInfo.columnSize ,
400
403
paramInfo.decimalDigits , dataPtr, bufferLength, strLenOrIndPtr);
401
404
if (!SQL_SUCCEEDED (rc)) {
402
405
LOG (" Error when binding parameter - {}" , paramIndex);
@@ -406,7 +409,7 @@ SQLRETURN BindParameters(SQLHANDLE hStmt, const py::list& params,
406
409
// https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/retrieve-numeric-data-sql-numeric-struct-kb222831?view=sql-server-ver16#sql_c_numeric-overview
407
410
if (paramInfo.paramCType == SQL_C_NUMERIC) {
408
411
SQLHDESC hDesc = nullptr ;
409
- RETCODE rc = SQLGetStmtAttr_ptr (hStmt, SQL_ATTR_APP_PARAM_DESC, &hDesc, 0 , NULL );
412
+ rc = SQLGetStmtAttr_ptr (hStmt, SQL_ATTR_APP_PARAM_DESC, &hDesc, 0 , NULL );
410
413
if (!SQL_SUCCEEDED (rc)) {
411
414
LOG (" Error when getting statement attribute - {}" , paramIndex);
412
415
return rc;
@@ -866,7 +869,7 @@ SQLRETURN SQLGetData_wrap(SqlHandlePtr StatementHandle, SQLUSMALLINT colCount, p
866
869
DriverLoader::getInstance ().loadDriver (); // Load the driver
867
870
}
868
871
869
- SQLRETURN ret;
872
+ SQLRETURN ret = SQL_SUCCESS ;
870
873
SQLHSTMT hStmt = StatementHandle->get ();
871
874
for (SQLSMALLINT i = 1 ; i <= colCount; ++i) {
872
875
SQLWCHAR columnName[256 ];
0 commit comments