Skip to content

FIX: Decode SQL_DATABASE_NAME in Connection.getinfo() - #771

Merged
Gaurav Sharma (bewithgaurav) merged 1 commit into
mainfrom
bewithgaurav/fix-762-database-name-getinfo
Sep 10, 2026
Merged

Gaurav Sharma (bewithgaurav) merged 1 commit into
mainfrom
bewithgaurav/fix-762-database-name-getinfo

Conversation

@bewithgaurav

@bewithgaurav Gaurav Sharma (bewithgaurav) commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Work Item / Issue Reference

GitHub Issue: #762

ADO Work Item: AB#48069


Summary

Decode SQL_DATABASE_NAME metadata using the same UTF-16LE path as other string-valued SQLGetInfo results. Extend the existing integration test to prevent embedded NUL characters from returning in the database name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 10, 2026 04:45
@github-actions github-actions Bot added the pr-size: small Minimal code update label Sep 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_NAME to the UTF-16LE decoding set in Connection.getinfo().
  • Extend the existing UTF-16 string decoding integration test to include SQL_DATABASE_NAME and 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.

@github-actions

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

83%


📈 Total Lines Covered: 7959 out of 9522
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No 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

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bewithgaurav
Gaurav Sharma (bewithgaurav) merged commit c025edf into main Sep 10, 2026
38 checks passed
Subrata (subrata-ms) added a commit that referenced this pull request Sep 11, 2026
[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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants