Skip to content

FEAT: Allow APP and Application Name in connection strings - #884

Merged
Jahnvi Thakkar (jahnvi480) merged 4 commits into
mainfrom
jahnvi/application-name-design
Nov 6, 2026
Merged

Jahnvi Thakkar (jahnvi480) merged 4 commits into
mainfrom
jahnvi/application-name-design

Conversation

@jahnvi480

@jahnvi480 Jahnvi Thakkar (jahnvi480) commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Work Item / Issue Reference

N/A

GitHub Issue: #484


Summary

  • Accept case-insensitive APP and Application Name values, producing MSSQL-Python|; omission keeps MSSQL-Python. Driver remains reserved.
  • Share application-name resolution across synchronous and async connections. Forward the effective name to row-based and Arrow bulk copy without double-prefixing.
  • Validate empty/type/Unicode/length errors before connecting. Limit the suffix to 115 UTF-16 code units without truncation, preserve whitespace and escaping, and retain existing override/alias precedence.
  • Extend existing tests for server-visible names, pooling isolation, malformed input, mixed Unicode boundaries, and escaped names at the length limit. No new test files or documentation files.

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.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 09:15
@github-actions github-actions Bot added the pr-size: medium Moderate update size label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

PR Performance Report

✅ No regression detected

No 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 diagnostics

Phase 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 timings

Unix / SQL Server 2022

Database task Before After Paired change Result
Connection opening 10.279 ms 10.081 ms -1.6% no signal
SELECT queries 0.982 ms 0.990 ms -0.2% no signal
Row insertion 32.256 ms 31.971 ms -1.0% no signal
Executemany inserts 159.051 ms 159.705 ms +0.3% no signal
Fetch-all queries 120.375 ms 120.189 ms -0.1% no signal
Row-by-row fetching 14.639 ms 14.291 ms -2.1% no signal
Batched row fetching 117.291 ms 117.376 ms +0.3% no signal
Transaction commit and rollback 106.271 ms 105.704 ms -0.5% no signal
Arrow row fetching 89.088 ms 89.952 ms +1.0% no signal
100,000-row insertion 430.930 ms 433.446 ms +0.6% no signal
Row fetching in batches of 100 123.729 ms 121.202 ms -1.6% no signal
Row fetching in batches of 10,000 124.726 ms 124.740 ms -1.3% no signal
Repeated positional queries 31.878 ms 32.520 ms +2.0% no signal
Repeated named-parameter queries 34.659 ms 33.900 ms -2.2% no signal
Legacy 100,000-row insertion 348.843 ms 349.218 ms +0.1% no signal
Insertion with explicit input sizes 478.849 ms 480.288 ms +0.3% no signal
Joined aggregation queries 174.908 ms 174.844 ms +0.1% no signal
Large joined-result fetching 186.808 ms 187.498 ms -0.9% no signal
1.2-million-row fetching 3438.233 ms 3436.388 ms -0.2% no signal
Common table expression queries 5.187 ms 5.196 ms -0.4% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.619 ms 1.531 ms -8.0% no signal
10,000 scalar values / fetchval() (debug disabled) 108.069 ms 107.964 ms -1.5% no signal
10,000 rows x 32 columns / dict(row._mapping) (warm) 31.265 ms 32.042 ms +1.9% no signal

Unix / SQL Server 2025

Database task Before After Paired change Result
Connection opening 96.623 ms 97.076 ms +0.6% no signal
SELECT queries 1.026 ms 1.045 ms +4.3% no signal
Row insertion 32.227 ms 32.527 ms +2.0% no signal
Executemany inserts 153.455 ms 151.880 ms +0.9% no signal
Fetch-all queries 119.997 ms 120.670 ms +0.3% no signal
Row-by-row fetching 14.423 ms 14.618 ms +0.9% no signal
Batched row fetching 119.201 ms 118.093 ms -2.5% no signal
Transaction commit and rollback 106.251 ms 106.738 ms +0.4% no signal
Arrow row fetching 90.084 ms 90.550 ms +0.8% no signal
100,000-row insertion 422.056 ms 422.559 ms +0.9% no signal
Row fetching in batches of 100 122.562 ms 123.002 ms -0.1% no signal
Row fetching in batches of 10,000 138.218 ms 139.212 ms +0.7% no signal
Repeated positional queries 31.887 ms 31.898 ms +0.2% no signal
Repeated named-parameter queries 34.198 ms 34.138 ms -1.2% no signal
Legacy 100,000-row insertion 338.390 ms 341.992 ms +1.4% no signal
Insertion with explicit input sizes 470.821 ms 475.587 ms +0.9% no signal
Joined aggregation queries 160.719 ms 160.521 ms -0.2% no signal
Large joined-result fetching 184.541 ms 181.923 ms +2.0% no signal
1.2-million-row fetching 3455.145 ms 3437.674 ms -0.6% no signal
Common table expression queries 5.121 ms 5.125 ms -0.5% no signal
256 KiB VARCHAR(MAX) / fetchall() 1.963 ms 1.698 ms -16.8% no signal
10,000 scalar values / fetchval() (debug disabled) 107.400 ms 108.188 ms -0.1% no signal
10,000 rows x 32 columns / dict(row._mapping) (warm) 32.619 ms 32.581 ms -0.4% no signal
Build and measurement details

ADO build 189910

PR head: 98190dc186410df9a161050a4c7b545a2c0bfba1
Base: 6b706f03dd681406be91e455d046f6f573cf8a7c
Measured merge: 53d9d331c595234177d31dcedc69e9f4d9a0fa30

  • Unix / SQL Server 2022: Python 3.12.3, x86_64, SQL 16.0.4305.5; 5 paired comparisons and 1 warmup.
  • Unix / SQL Server 2025: Python 3.12.3, x86_64, SQL 17.0.5035.5; 5 paired comparisons and 1 warmup.

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 profiler-* artifacts.

Comment thread tests/test_003_connection.py Fixed
Comment thread tests/test_003_connection.py Fixed
Comment thread tests/test_003_connection.py Fixed

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

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 APP and Application Name aliases; Driver remains 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

Copilot AI balanced review requested due to automatic review settings November 6, 2026 09:18

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.

🔵 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>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 09:23

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.

🔵 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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

96%


🎯 Overall Coverage

85%


📈 Total Lines Covered: 10491 out of 12320
📁 Project: mssql-python


Diff Coverage

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

  • mssql_python/async_query/_connection_context.py (100%)
  • mssql_python/connection.py (100%)
  • mssql_python/connection_string_builder.py (100%)
  • mssql_python/constants.py (100%)
  • mssql_python/helpers.py (94.1%): Missing lines 259

Summary

  • Total: 26 lines
  • Missing: 1 line
  • Coverage: 96%

mssql_python/helpers.py

Lines 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

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

Copilot AI balanced review requested due to automatic review settings November 6, 2026 09:53

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.

🔵 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

@jahnvi480
Jahnvi Thakkar (jahnvi480) merged commit 8603956 into main Nov 6, 2026
38 checks passed
Jahnvi Thakkar (jahnvi480) added a commit that referenced this pull request Nov 18, 2026
[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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: medium Moderate update size

4 participants