FIX: Fixing Level 3 and level 4 compiler warnings. #72
+40
−30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
AB#37476
This pull request focuses on improving type safety, enhancing error handling, and adding utility functions in the
mssql_python/pybind
module. The changes primarily involve the use of explicit type casting, the introduction of aWideToUTF8
utility function for string conversion, and minor fixes to improve code clarity and correctness.Type Safety Improvements:
std::make_shared<SqlHandle>
calls across multiple functions inconnection.cpp
to usestatic_cast<SQLSMALLINT>
for handle types (SQL_HANDLE_ENV
,SQL_HANDLE_DBC
,SQL_HANDLE_STMT
) to ensure explicit type casting. [1] [2] [3]BindParameters
to useSQLSMALLINT
orSQLUSMALLINT
instead ofint
. [1] [2] [3]SQLSetStmtAttr_ptr
andSQLSetConnectAttr_ptr
calls to usereinterpret_cast
orstatic_cast
for pointer conversions, ensuring type correctness. [1] [2] [3]Error Handling Enhancements:
LoadDriverOrThrowException
with the newWideToUTF8
utility function for better readability and consistency.WideToUTF8
function inddbc_bindings.cpp
and declared it inddbc_bindings.h
to handlestd::wstring
tostd::string
conversions. [1] [2]Connection::checkError
by usingWideToUTF8
for converting wide error messages to UTF-8.Code Fixes and Cleanup:
std::memset
inBindParameters
to correct the namespace usage.SQLGetData_wrap
initialization.SQLGetData_wrap
andFetchBatchData
to usestatic_cast<size_t>
for comparingdataLen
withcolumnSize
. [1] [2]These changes collectively enhance the robustness, maintainability, and readability of the code.
Checklist