FIX: accept timeout=0 in bulkcopy as no timeout - #698
Draft
bewithgaurav wants to merge 1 commit into
Draft
Conversation
the BCP API spec documents timeout 0 as no timeout, and mssql-py-core implements it that way (BulkCopyTimeoutState::from_seconds maps 0 to an infinite deadline). the python layer rejected it with a 'timeout must be positive' guard that has been in place since the feature shipped, so the documented value never worked. relaxes the bound to '< 0', matching what batch_size already does. bool is excluded explicitly since it is an int subclass and False would otherwise slip through as 0 and silently disable the timeout. negatives stay rejected, py-core takes an unsigned value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| from mssql_python.cursor import Cursor | ||
|
|
||
| mock_conn = MagicMock() | ||
| mock_conn.connection_str = "Server=localhost;Database=testdb;UID=sa;PWD=mypwd" |
📊 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: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.9%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 76.3%
mssql_python.__init__.py: 77.3%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 81.4%
mssql_python.pybind.connection.connection.cpp: 83.7%
mssql_python.connection.py: 84.7%🔗 Quick Links
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
bulkcopy()rejectedtimeout=0with "timeout must be positive", but the BCP API spec documents 0 as no timeout and mssql-py-core implements it that way (BulkCopyTimeoutState::from_secondsmaps 0 to an infinite deadline). the guard has been there since the feature shipped, so the documented value never worked.relaxes the bound to
< 0, matching whatbatch_sizealready does. bool is excluded explicitly since it is an int subclass andFalsewould otherwise slip through as 0 and silently disable the timeout. negatives stay rejected since py-core takes an unsigned value.three tests: a live copy with
timeout=0, a mocked assertion that 0 reaches py-core unchanged rather than being swapped for the 30s default, and rejection cases for negatives, floats and bools.