FIX: Invalid check for database in connection string in _bulkcopy#445
FIX: Invalid check for database in connection string in _bulkcopy#445subrata-ms merged 7 commits intomainfrom
Conversation
📊 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.hpp: 58.8%
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.row.py: 66.2%
mssql_python.pybind.ddbc_bindings.cpp: 69.4%
mssql_python.pybind.ddbc_bindings.h: 69.7%
mssql_python.pybind.connection.connection.cpp: 75.3%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.cursor.py: 84.7%
mssql_python.__init__.py: 84.9%🔗 Quick Links
|
There was a problem hiding this comment.
Pull request overview
Updates bulk copy connection-string validation so DATABASE is no longer required, matching SQL Server’s default-database behavior, and adds tests to validate bulk copy behavior when DATABASE is omitted.
Changes:
- Remove the
_bulkcopy()hard requirement thatDATABASEbe present in the connection string. - Add an integration test validating bulk copy works when
DATABASEis omitted. - Add tests around
SERVERparameter handling (including synonyms and missing-server failure).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
mssql_python/cursor.py |
Removes the DATABASE-required guard; keeps a guard ensuring some server key is present before starting py-core bulk copy. |
tests/test_019_bulkcopy.py |
Adds new bulk copy integration tests for missing DATABASE, server-key synonyms, and missing server failure behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The new tests are failing in test pipeline - |
Summary
This pull request updates the bulk copy functionality to make the
DATABASEparameter in the connection string optional, aligning behavior with SQL Server's default handling. It also adds a new test to ensure this works as expected. The most important changes are:Bulk copy connection string handling:
_bulkcopymethod incursor.pyto remove the requirement for theDATABASEparameter in the connection string; now, bulk copy will proceed as long as a server is specified, and the server will use the default database if none is provided.Testing improvements:
test_bulkcopy_without_database_parameter, intest_019_bulkcopy.pyto verify that bulk copy works correctly when theDATABASEparameter is omitted, ensuring the client connects to the default database and data is inserted as expected.