Skip to content

Commit a0bf20f

Browse files
committed
fix(bulkcopy): correct Arrow-steering message (tuples/Row, add __arrow_c_array__); use non-localhost host in unit-test conn strings
1 parent ebf5a5c commit a0bf20f

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎mssql_python/cursor.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,9 +3026,10 @@ def bulkcopy(
30263026
# silently re-routing or failing deep inside the tuple validator.
30273027
if self._looks_like_arrow_source(data):
30283028
raise TypeError(
3029-
"bulkcopy() expects an iterable of row tuples/lists. "
3029+
"bulkcopy() expects an iterable of row tuples or Row objects. "
30303030
"For pyarrow.Table / RecordBatch / RecordBatchReader / objects "
3031-
"implementing __arrow_c_stream__, call cursor.bulkcopy_arrow() instead."
3031+
"implementing __arrow_c_stream__/__arrow_c_array__, call "
3032+
"cursor.bulkcopy_arrow() instead."
30323033
)
30333034

30343035
try:

‎tests/test_024_bulkcopy_arrow.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_missing_server_raises(self):
226226

227227
def test_sql_auth_keeps_credentials(self):
228228
cur = _cursor_with_conn(
229-
"Server=localhost;Database=testdb;UID=sa;PWD=mypwd", auth_type=None
229+
"Server=testhost;Database=testdb;UID=sa;PWD=mypwd", auth_type=None
230230
)
231231
ctx = cur._build_pycore_context()
232232
assert ctx.get("user_name") == "sa"
@@ -352,7 +352,7 @@ class TestBulkcopyArrowDispatch:
352352
@patch("mssql_python.cursor.logger")
353353
def test_success_returns_result_and_forwards_args(self, mock_logger):
354354
mock_logger.is_debug_enabled = False
355-
cur = _cursor_with_conn("Server=localhost;Database=d;UID=sa;PWD=p")
355+
cur = _cursor_with_conn("Server=testhost;Database=d;UID=sa;PWD=p")
356356
module, pyc_cursor, _, _ = _mock_pycore()
357357
src = pa.table({"a": [1, 2]})
358358

@@ -374,7 +374,7 @@ def test_success_returns_result_and_forwards_args(self, mock_logger):
374374
def test_batch_size_timeout_accept_positional(self, mock_logger):
375375
"""D13: batch_size/timeout are positional-or-keyword (parity with bulkcopy)."""
376376
mock_logger.is_debug_enabled = False
377-
cur = _cursor_with_conn("Server=localhost;Database=d;UID=sa;PWD=p")
377+
cur = _cursor_with_conn("Server=testhost;Database=d;UID=sa;PWD=p")
378378
module, pyc_cursor, _, _ = _mock_pycore()
379379
src = pa.table({"a": [1, 2]})
380380

@@ -389,7 +389,7 @@ def test_batch_size_timeout_accept_positional(self, mock_logger):
389389
@patch("mssql_python.cursor.logger")
390390
def test_sensitive_fields_cleared_after_success(self, mock_logger):
391391
mock_logger.is_debug_enabled = False
392-
cur = _cursor_with_conn("Server=localhost;Database=d;UID=sa;PWD=secret")
392+
cur = _cursor_with_conn("Server=testhost;Database=d;UID=sa;PWD=secret")
393393
module, _, _, captured = _mock_pycore()
394394

395395
with patch.dict("sys.modules", {"mssql_py_core": module}):
@@ -402,7 +402,7 @@ def test_sensitive_fields_cleared_after_success(self, mock_logger):
402402
@patch("mssql_python.cursor.logger")
403403
def test_resources_closed_on_success(self, mock_logger):
404404
mock_logger.is_debug_enabled = False
405-
cur = _cursor_with_conn("Server=localhost;Database=d;UID=sa;PWD=p")
405+
cur = _cursor_with_conn("Server=testhost;Database=d;UID=sa;PWD=p")
406406
module, pyc_cursor, pyc_conn, _ = _mock_pycore()
407407

408408
with patch.dict("sys.modules", {"mssql_py_core": module}):
@@ -414,7 +414,7 @@ def test_resources_closed_on_success(self, mock_logger):
414414
@patch("mssql_python.cursor.logger")
415415
def test_core_exception_is_reraised_and_cleaned_up(self, mock_logger):
416416
mock_logger.is_debug_enabled = False
417-
cur = _cursor_with_conn("Server=localhost;Database=d;UID=sa;PWD=p")
417+
cur = _cursor_with_conn("Server=testhost;Database=d;UID=sa;PWD=p")
418418
module, pyc_cursor, pyc_conn, captured = _mock_pycore(
419419
raise_exc=ValueError("boom")
420420
)
@@ -432,7 +432,7 @@ def test_core_exception_is_reraised_and_cleaned_up(self, mock_logger):
432432
def test_cleanup_swallows_close_errors(self, mock_logger):
433433
"""A failing resource.close() during teardown must not mask the result."""
434434
mock_logger.is_debug_enabled = False
435-
cur = _cursor_with_conn("Server=localhost;Database=d;UID=sa;PWD=p")
435+
cur = _cursor_with_conn("Server=testhost;Database=d;UID=sa;PWD=p")
436436
module, pyc_cursor, pyc_conn, _ = _mock_pycore()
437437
pyc_cursor.close.side_effect = RuntimeError("close failed")
438438

0 commit comments

Comments
 (0)