-
Notifications
You must be signed in to change notification settings - Fork 31
REFACTOR: modularize ddbc_bindings.cpp #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modularizes the native ODBC binding layer by extracting common typedefs, utilities, and wrappers out of ddbc_bindings.cpp into a dedicated header, improving separation of concerns and reuse.
- Added function pointer typedefs and
externdeclarations for all ODBC APIs inddbc_bindings.h. - Introduced logging and exception helper declarations (
LOG,ThrowStdException,LoadDriverOrThrowException). - Added singleton
DriverLoaderand RAII-styleSqlHandlewrapper classes.
Comments suppressed due to low confidence (3)
mssql_python/pybind/ddbc_bindings.h:135
- [nitpick] Private member naming is inconsistent:
DriverLoaderusesm_prefix but here_typeuses a leading underscore. Consider usingm_typeandm_handleto align withm_driverLoaded.
SQLSMALLINT _type;
mssql_python/pybind/ddbc_bindings.h:108
- [nitpick] The name
LOGis very generic and could collide with other logging macros or symbols. Consider a more specific name or namespace qualification (e.g.,DDBC_LOG).
void LOG(const std::string& formatString, Args&&... args);
mssql_python/pybind/ddbc_bindings.h:107
- The template function LOG is only declared here but has no inline definition, which will lead to linker errors. Move its implementation into this header or mark it inline.
template <typename... Args>
sumitmsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring is a positive step towards better code organization and maintainability. The introduction of the DriverLoader singleton and the move of declarations to a header file are good improvements. The main areas to focus on for further improvement and to ensure robustness are cross-platform compatibility (if applicable), GIL handling for Python callbacks, and thorough testing.
I have left a few comments, let's discuss and resolve them.
bewithgaurav
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some context and minor suggestions in places wherever needed.
d63a44a to
1182190
Compare
sumitmsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good. PR ready for merge.
ADO Task ID AB#37534
This pull request introduces a new header file,
ddbc_bindings.h, for managing SQL database interactions in themssql_pythonmodule. The file provides function pointer typedefs for SQL APIs, extern declarations for these function pointers, and utility classes and functions for logging, exception handling, driver loading, and SQL handle management.Summary
Refactored the native layer to clearly separate binding logic and ODBC utility functions. This decouples the tightly integrated components from ddbc_bindings.cpp. This has been done to improve modularity, reusability, and maintainability of the native C++ layer to support cross-platform development.
We have also introduced core utilities such as SqlHandle and DriverLoader to promote reuse and reduce redundancy.
Checklist
Testing Performed
The changes were verified against all the pytests on Windows. (current support)