FIX: Decode SQL_DATABASE_NAME in Connection.getinfo() - #771
Gaurav Sharma (bewithgaurav) merged 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, aligns with existing decoding behavior, and is covered by an integration test update targeting the reported regression.
Pull request overview
This PR fixes Connection.getinfo(SQL_DATABASE_NAME) returning strings with embedded NUL characters by treating SQL_DATABASE_NAME as a UTF-16LE string-valued SQLGetInfo result, consistent with other string metadata fields.
Changes:
- Add
GetInfoConstants.SQL_DATABASE_NAMEto the UTF-16LE decoding set inConnection.getinfo(). - Extend the existing UTF-16 string decoding integration test to include
SQL_DATABASE_NAMEand assert there are no embedded NULs.
File summaries
| File | Description |
|---|---|
| mssql_python/connection.py | Includes SQL_DATABASE_NAME in the set of SQLGetInfo constants decoded as UTF-16LE. |
| tests/test_003_connection.py | Adds SQL_DATABASE_NAME to the UTF-16 decoding verification list to prevent regressions with embedded NULs. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changesNo lines with coverage information in this diff. 📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 61.5%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 77.5%
mssql_python.row.py: 77.6%
mssql_python.pybind.connection.connection_pool.cpp: 81.6%
mssql_python.pybind.connection.connection.cpp: 84.4%
mssql_python.logging.py: 85.5%
mssql_python.helpers.py: 89.3%
mssql_python.pooling.py: 90.1%🔗 Quick Links
|
Sumit Sarabhai (sumitmsft)
left a comment
There was a problem hiding this comment.
PR #771: Adding SQL_DATABASE_NAME to the string-type set correctly routes the SQLGetInfoW result through the existing UTF-16LE decoding path. No actionable findings in the reviewed changes.
[AB#48121](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/48121) ### Summary #### Enhancements - Add selectable native ODBC providers (#730). - Route `setinputsizes()` through the native C++ execution pipeline (#736). - Accept `memoryview` values in `Binary()` (#741). - Expose SQL Server type constants at module level (#764). #### Bug Fixes - Prevent concurrent logging deadlocks (#678). - Vendor the correct `mssql_py_core` architecture in Windows ARM64 wheels (#737). - Resolve bundled Windows driver and authentication DLLs from package-local directories (#735). - Bind `Decimal` parameters consistently as `SQL_NUMERIC` (#742). - Use ODBC 3.x parameter types (#758). - Decode `SQL_DATABASE_NAME` metadata (#771). - Prevent shutdown crashes during mixed cursor cleanup (#772). Bumps the package version from 1.14.0 to 1.15.0 and refreshes the PyPI release summary. --------- Co-authored-by: Gaurav Sharma <sharmag@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Work Item / Issue Reference
Summary
Decode
SQL_DATABASE_NAMEmetadata using the same UTF-16LE path as other string-valuedSQLGetInforesults. Extend the existing integration test to prevent embedded NUL characters from returning in the database name.