Skip to content

Conversation

@bewithgaurav
Copy link
Collaborator

@bewithgaurav bewithgaurav commented Jan 23, 2026

Work Item / Issue Reference

AB#41850

GitHub Issue: #<ISSUE_NUMBER>


Summary

The mssql-py-core API expects kwargs as a dict parameter (kwargs=dict), not as Python keyword arguments (**kwargs).

Before: pycore_cursor.bulkcopy(table_name, iter(data), **kwargs)
After: pycore_cursor.bulkcopy(table_name, iter(data), kwargs=kwargs)

This pull request updates the way keyword arguments are passed to the bulkcopy method in the mssql_python/cursor.py file. The main change ensures compatibility with the Rust API by passing kwargs as a dictionary parameter rather than as Python keyword arguments.

  • Changed the call to pycore_cursor.bulkcopy to pass kwargs as a dictionary using the kwargs parameter, aligning with the expectations of the Rust API.

The Rust API expects kwargs as a dict parameter (kwargs=dict),
not as Python keyword arguments (**kwargs).

Before: pycore_cursor.bulkcopy(table_name, iter(data), **kwargs)
After:  pycore_cursor.bulkcopy(table_name, iter(data), kwargs=kwargs)
@github-actions
Copy link

github-actions bot commented Jan 23, 2026

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

76%


📈 Total Lines Covered: 5431 out of 7084
📁 Project: mssql-python


Diff Coverage

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

No 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: 73.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 79.6%
mssql_python.connection.py: 84.1%
mssql_python.cursor.py: 84.7%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

@bewithgaurav bewithgaurav marked this pull request as ready for review January 28, 2026 09:22
Copilot AI review requested due to automatic review settings January 28, 2026 09:22
@bewithgaurav bewithgaurav changed the title TEST: Fix _bulkcopy kwargs passing to mssql_py_core FIX: _bulkcopy kwargs passing to mssql_py_core Jan 28, 2026
@github-actions github-actions bot added the pr-size: small Minimal code update label Jan 28, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in how keyword arguments are passed to the mssql_py_core Rust API's bulkcopy method. The previous implementation incorrectly used Python's **kwargs unpacking syntax, but the Rust API expects kwargs as a named dictionary parameter.

Changes:

  • Updated the pycore_cursor.bulkcopy() call to pass kwargs as a named parameter (kwargs=kwargs) instead of unpacking with **kwargs
  • Added clarifying comments explaining the Rust API's expected signature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# 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.
The Rust API now accepts **kwargs directly, so we can use the cleaner Python syntax.
@bewithgaurav bewithgaurav changed the title FIX: _bulkcopy kwargs passing to mssql_py_core TEST: _bulkcopy kwargs passing to mssql_py_core Jan 28, 2026
@bewithgaurav
Copy link
Collaborator Author

closing the test PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants