Skip to content

FEAT: complete macOS-support with main ddbc_bindings and connection pooling #102

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

Merged
merged 4 commits into from
Jun 27, 2025

Conversation

gargsaumya
Copy link
Contributor

@gargsaumya gargsaumya commented Jun 25, 2025

This pull request refactors the mssql_python module to remove macOS-specific implementations and unify the codebase for better maintainability. Key changes include removing the connection_mac.py file, updating connection handling to use UTF-8 strings, and modifying build configurations to eliminate platform-specific blocks.

Removal of macOS-specific implementations:

  • mssql_python/connection_mac.py: Deleted the entire file, which contained macOS-specific implementations of the Connection class. This eliminates platform-specific handling in favor of a unified approach.
  • mssql_python/db_connection.py: Removed conditional imports for macOS and updated the Connection import to use the unified implementation.
  • mssql_python/pybind/CMakeLists.txt: Removed the conditional block for macOS-specific source files (ddbc_bindings_mac.cpp) and standardized the build process to use ddbc_bindings.cpp.

Transition to UTF-8 string handling:

Minor adjustments:

Issue Reference

AB#37666
AB#37610

@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 09:16
@gargsaumya gargsaumya changed the base branch from main to saumya/mac-sqlwchar June 25, 2025 09:17
Copy link
Contributor

@Copilot Copilot AI left a 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 unifies and refactors ODBC connection handling for both macOS and Windows by removing the old macOS-only implementation, consolidating platform-specific logic into shared modules, and enhancing debugging through detailed logging of parameter binding.

  • Consolidated connection logic: removed connection_mac.py and related CMake logic, updated ConnectionHandle to use UTF-8 strings everywhere
  • Added wide-char/UTF-8 conversion utilities and detailed parameter-binding logs in ddbc_bindings.*
  • Swapped Windows‐only headers for std::filesystem and introduced platform‐agnostic driver‐loading helpers

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pybind/mac_utils.h Added license, header comments for macOS wide-char utilities
pybind/ddbc_bindings.h Unified platform includes and added inline UTF-8/wstring helpers
pybind/ddbc_bindings.cpp Swapped to std::filesystem, added detailed logging, driver helpers
pybind/connection/connection.* Updated ConnectionHandle to accept std::string and convert to wide
pybind/CMakeLists.txt Removed macOS-specific blocks, always build unified source
db_connection.py Dropped conditional import of macOS connection implementation
connection_pool.cpp Removed unused <iostream> include
Comments suppressed due to low confidence (2)

mssql_python/pybind/ddbc_bindings.h:49

  • The header uses std::vector but does not include . Add "#include " near the top to ensure this compiles.
    inline std::vector<SQLWCHAR> WStringToSQLWCHAR(const std::wstring& str) {

mssql_python/pybind/ddbc_bindings.h:20

  • [nitpick] The IS_WINDOWS macro is defined but never referenced elsewhere; consider removing it or using it consistently to reduce unused code.
    #define IS_WINDOWS 1

@gargsaumya gargsaumya changed the title FEAT: improved cross-platform compatibility for macOS and Windows FEAT: complete macos-support with main ddbc_bindings and smart pointers Jun 25, 2025
@gargsaumya gargsaumya changed the title FEAT: complete macos-support with main ddbc_bindings and smart pointers FEAT: complete macOS-support with main ddbc_bindings and smart pointers Jun 25, 2025
@gargsaumya gargsaumya changed the title FEAT: complete macOS-support with main ddbc_bindings and smart pointers FEAT: complete macOS-support with main ddbc_bindings and connection pooling Jun 25, 2025
@Ramudaykumar
Copy link
Contributor

Ensure that every SQL call (e.g., SQLAllocHandle_ptr, SQLDriverConnect_ptr) is followed by proper error handling using checkError(ret); or equivalent logic.

@Ramudaykumar
Copy link
Contributor

I can't see test.py for DDBC covering connect_pool changes, consider adding those.

@gargsaumya
Copy link
Contributor Author

gargsaumya commented Jun 26, 2025

I can't see test.py for DDBC covering connect_pool changes, consider adding those.

Yes, those have been added in another PR. #103

Ramudaykumar
Ramudaykumar previously approved these changes Jun 27, 2025
bewithgaurav
bewithgaurav previously approved these changes Jun 27, 2025
@gargsaumya gargsaumya changed the base branch from saumya/mac-sqlwchar to main June 27, 2025 08:16
@gargsaumya gargsaumya dismissed stale reviews from bewithgaurav and Ramudaykumar June 27, 2025 08:16

The base branch was changed.

@gargsaumya gargsaumya force-pushed the saumya/mac-full-support branch from f6f1af8 to 1dbd1fb Compare June 27, 2025 08:41
@gargsaumya gargsaumya force-pushed the saumya/mac-full-support branch 3 times, most recently from c35629f to 231c4b0 Compare June 27, 2025 08:54
@gargsaumya gargsaumya force-pushed the saumya/mac-full-support branch from 231c4b0 to a41f35d Compare June 27, 2025 08:55
@gargsaumya gargsaumya merged commit 918b328 into main Jun 27, 2025
9 checks passed
@gargsaumya gargsaumya mentioned this pull request Jul 1, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants