FIX: Fixing Level 3 and level 4 compiler warnings. #72
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/pybindmodule. The changes primarily involve the use of explicit type casting, the introduction of aWideToUTF8utility 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.cppto usestatic_cast<SQLSMALLINT>for handle types (SQL_HANDLE_ENV,SQL_HANDLE_DBC,SQL_HANDLE_STMT) to ensure explicit type casting. [1] [2] [3]BindParametersto useSQLSMALLINTorSQLUSMALLINTinstead ofint. [1] [2] [3]SQLSetStmtAttr_ptrandSQLSetConnectAttr_ptrcalls to usereinterpret_castorstatic_castfor pointer conversions, ensuring type correctness. [1] [2] [3]Error Handling Enhancements:
LoadDriverOrThrowExceptionwith the newWideToUTF8utility function for better readability and consistency.WideToUTF8function inddbc_bindings.cppand declared it inddbc_bindings.hto handlestd::wstringtostd::stringconversions. [1] [2]Connection::checkErrorby usingWideToUTF8for converting wide error messages to UTF-8.Code Fixes and Cleanup:
std::memsetinBindParametersto correct the namespace usage.SQLGetData_wrapinitialization.SQLGetData_wrapandFetchBatchDatato usestatic_cast<size_t>for comparingdataLenwithcolumnSize. [1] [2]These changes collectively enhance the robustness, maintainability, and readability of the code.
Checklist