Repository navigation
FEAT: Allow APP and Application Name in connection strings - #884
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PR Performance Report✅ No regression detectedNo consistent slowdowns detected across all 2 environments. 0 IMPROVEMENTS 0 SLOWDOWNS 2/2 ENVIRONMENTS Coverage: 2 of 2 environments completed. Advisory result; does not block merging. Performance diagnosticsPhase times are inclusive diagnostics and must not be added together. They identify where measured time changed, not why it changed. No affected phases or call-count changes were recorded. All database tasks and timingsUnix / SQL Server 2022
Unix / SQL Server 2025
Build and measurement detailsPR head:
A consistent change requires more than 20% median paired movement, at least 1 ms between the median runtimes, and at least 80% of pairs exceeding the relative threshold in the same direction. A slowdown without enough pair agreement is reported as inconsistent. The displayed change is the median of paired before-and-after ratios. It is not recalculated from the two displayed median runtimes. Both revisions use profiling-enabled builds on the same agent and database, with alternating order and discarded warmups. Results are diagnostic and do not represent production-wheel latency. Raw samples and logs are attached to the ADO run as |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the custom application-name changes.
No open issues 🎉
What changed in this PR
Addresses #484 by allowing custom application names in connection strings while retaining the driver’s MSSQL-Python identifier across synchronous, async, and bulk-copy connections.
Changes:
- Accepts case-insensitive
APPandApplication Namealiases;Driverremains reserved. - Shares name validation and prefixing, enforces the 128 UTF-16-unit total limit, and preserves whitespace and escaping.
- Adds coverage for server-visible names, invalid inputs, alias precedence, bulk-copy inheritance, and pool isolation.
| File | Description |
|---|---|
| tests/test_012_connection_string_integration.py | Replaces APP-rejection tests with acceptance and server-value checks. |
| tests/test_011_connection_string_allowlist.py | Verifies alias normalization and APP preservation. |
| tests/test_010_connection_string_parser.py | Updates normalization expectations to retain APP. |
| tests/test_009_pooling.py | Tests name-based pool isolation and alias session reuse. |
| tests/test_003_connection.py | Adds validation, Unicode boundary, and bulk-copy name tests. |
| tests/AsyncTest/test_002_async_connection.py | Tests async validation and server-visible names. |
| mssql_python/helpers.py | Adds shared name resolution and forwarding to the Rust backend. |
| mssql_python/constants.py | Defines name defaults and limits; allows both aliases. |
| mssql_python/connection.py | Validates and resolves names after merging connection options. |
| mssql_python/connection_string_parser.py | Updates comments to reflect APP preservation. |
| mssql_python/connection_string_builder.py | Braces values containing whitespace to preserve them. |
| mssql_python/async_query/_connection_context.py | Applies shared name resolution to async connections. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Unicode/escaping boundaries, pool isolation, and application-name propagation across ODBC and Rust/TDS require live SQL Server validation that could not be performed in this review environment.
No open issues 🎉
Review effort: Balanced
Replace synthetic localhost inputs flagged by DevSkim. Live SQL Server tests continue to use DB_CONNECTION_STRING. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Live SQL Server validation was unavailable for UTF-16 boundary handling, escaped application names, pooling isolation, and application-name inheritance across ODBC, async TDS, and Rust-backed bulk-copy sessions.
No open issues 🎉
Review effort: Balanced
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
mssql_python/helpers.pyLines 255-263 255 """Resolve a raw application name once, before transport serialization."""
256 if user_app_name is None:
257 return _DEFAULT_APP_NAME
258 if not isinstance(user_app_name, str):
! 259 raise TypeError("Application name must be a string")
260 if not user_app_name:
261 raise ValueError("Application name must not be empty")
262
263 app_name = f"{_DEFAULT_APP_NAME}|{user_app_name}"📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 62.6%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.connection.connection_pool.cpp: 81.3%
mssql_python.pybind.row_mapping_cache.hpp: 81.5%
mssql_python.pybind.connection.connection.cpp: 82.5%
mssql_python.logging.py: 86.2%
mssql_python.pybind.row_mapping.hpp: 86.8%
mssql_python.pooling.py: 90.1%🔗 Quick Links
|
There was a problem hiding this comment.
🔵 Needs a closer look
UTF-16 boundaries, escaped names, pool isolation, and application-name forwarding across ODBC and Rust-backed async/bulk-copy sessions require live, cross-platform SQL Server validation unavailable in this review environment.
No open issues 🎉
Review effort: Balanced
[AB#50320](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/50320) ### Summary Prepare mssql-python 1.18.0 using the approved customer-facing change inventory since v1.17.0. #### Enhancements - Accept APP/Application Name across synchronous, async and bulk-copy paths; note the async/bulk-copy default application-name change to MSSQL-Python (#884). - Reduce row-to-dictionary, single-row fetch, output-converter batch and fetchmany(1) text-processing overhead (#847, #858, #852, #891). - Cache single-pass pyformat conversion and retain compatible parameter bindings for prepared-statement reuse (#888, #886). - Include mssql-python-rs 0.5.0 improvements: Rust-backed execution, macOS Strict TLS and table-valued parameters in the opt-in Rust ODBC provider (#896). #### Bug Fixes - Avoid unsupported isolation reset when closing pooled Azure Synapse connections (#889). - Respect explicit positive connection timeouts during pooled checkout (#897). - Coordinate Arrow reader cross-thread shutdown/cancellation (#892). - Preserve SQL literal, identifier, comment and escaped-percent behavior during pyformat conversion (#888). - Include Rust-backed timeout, prepared-statement lifetime/cancellation, isolation-change, small-stack connection, streaming-order and SQL_VARIANT decoding fixes (#896). #### Version - Bump mssql_python.__version__ and setup.py from 1.17.0 to 1.18.0. - Replace the previous PyPI highlights with the approved 1.18.0 inventory. - Change exactly three release files; no runtime implementation or dependency-pin changes in this PR. ### Validation - Passed: pinned full-directory Black check, staged Python formatting hook, release-version/highlights/approved-PR inventory checks, and git diff --check. - Not run locally: native rebuild and full integration suite. The isolated project environment lacks runtime/test dependencies and DB_CONNECTION_STRING is unset. No integration-test success is claimed; release qualification remains required. ### Release gates - Keep this PR unmerged until the required PyPI and Conda release/verification gates complete. - Rust dependency verified: mssql-python-rs==0.5.0 was built successfully by ADO build 191702 from stable commit 2f6ab0fa…. Release run 191738 successfully verified/staged and published the wheels through ESRP. All nine wheels are non-yanked on PyPI, and their advertised SHA256 digests match the staging log. There is no wheel-build or publication blocker. The overall release run failed on Guardian findings and dependency-update automation; any required Guardian disposition remains separate and unresolved. - Rust release-source comparison: 0.4.0 at 0c3e3c1436b1234d4e838087ff11140ba68b43a5 to 0.5.0 at 2f6ab0faf2a3a4dbad7dc8f0c4cfe2980eabf41d, verified against version declarations and ADO release sources. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jahnvi Thakkar <61936179+jahnvi480@users.noreply.github.com>
Work Item / Issue Reference
Summary
Compatibility: async and bulk-copy defaults change from mssql-python to MSSQL-Python. Telemetry collectors matching the old exact name must also recognize MSSQL-Python|... before applications adopt custom names.