Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mssql_python/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,11 @@ def _bulkcopy(
pycore_connection = mssql_py_core.PyCoreConnection(pycore_context)
pycore_cursor = pycore_connection.cursor()

result = pycore_cursor.bulkcopy(table_name, iter(data), **kwargs)
# Pass kwargs as a dict parameter, not as Python keyword arguments
# The Rust API expects: bulkcopy(table_name, data_source, kwargs=dict)
result = pycore_cursor.bulkcopy(
table_name, iter(data), kwargs=kwargs if kwargs else None
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional expression kwargs if kwargs else None will pass None when kwargs is an empty dict, since empty dicts are falsy in Python. This means when _bulkcopy is called without any kwargs, None will be passed to the Rust API instead of an empty dict. Consider whether the Rust API expects None or an empty dict when no options are provided. If an empty dict should always be passed, change this to just kwargs=kwargs.

Suggested change
table_name, iter(data), kwargs=kwargs if kwargs else None
table_name, iter(data), kwargs=kwargs

Copilot uses AI. Check for mistakes.
)

return result

Expand Down
Loading