Skip to content

Conversation

@subrata-ms
Copy link
Contributor

@subrata-ms subrata-ms commented Nov 17, 2025

AB#39794

GitHub Issue: #273


Summary

This pull request adds support for binding arrays of NULL parameters in SQL statements and introduces a corresponding test to ensure correct behavior when executing multiple inserts with only NULL values. The main focus is on handling the SQL_C_DEFAULT type for parameter arrays, ensuring all values are NULL, and verifying this functionality through unit testing.

Parameter binding improvements:

  • Added logic to BindParameterArray in ddbc_bindings.cpp to handle the SQL_C_DEFAULT type, ensuring that arrays of NULL values are properly bound and validated. If any non-NULL value is detected, an exception is thrown.

Testing enhancements:

  • Added a new test test_executemany_NONE_parameter_list in test_004_cursor.py to verify that executemany correctly inserts rows with all NULL values and that the count matches the expected number of inserts.

Copilot AI review requested due to automatic review settings November 17, 2025 14:44
@github-actions github-actions bot added the pr-size: small Minimal code update label Nov 17, 2025
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 pull request fixes an issue with the data type mapping for NULL parameters in the _map_sql_type function. The change updates the C type for NULL parameters from SQL_C_DEFAULT (99) to SQL_C_CHAR (-8), which aligns with the SQL type SQL_VARCHAR that's also returned for NULL parameters.

Key changes:

  • Updated the C type for NULL parameters in _map_sql_type from SQL_C_DEFAULT to SQL_C_CHAR to match the SQL_VARCHAR SQL type being used

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

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

📊 Code Coverage Report

🔥 Diff Coverage

92%


🎯 Overall Coverage

74%


📈 Total Lines Covered: 5278 out of 7042
📁 Project: mssql-python


Diff Coverage

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

  • mssql_python/pybind/ddbc_bindings.cpp (92.3%): Missing lines 2462

Summary

  • Total: 13 lines
  • Missing: 1 line
  • Coverage: 92%

mssql_python/pybind/ddbc_bindings.cpp

Lines 2458-2466

  2458                     dataPtr = nullBuffer;
  2459                     bufferLength = 1;
  2460                     LOG("BindParameterArray: SQL_C_DEFAULT bound - param_index=%d", paramIndex);
  2461                     break;
! 2462                 }
  2463                 default: {
  2464                     LOG("BindParameterArray: Unsupported C type - "
  2465                         "param_index=%d, C_type=%d",
  2466                         paramIndex, info.paramCType);


📋 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: 66.3%
mssql_python.helpers.py: 67.5%
mssql_python.pybind.connection.connection.cpp: 73.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.connection.py: 83.5%
mssql_python.cursor.py: 84.4%
mssql_python.__init__.py: 84.9%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

gargsaumya
gargsaumya previously approved these changes Nov 26, 2025
Copy link
Contributor

@sumitmsft sumitmsft left a comment

Choose a reason for hiding this comment

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

Left a few comments to address

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: small Minimal code update labels Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: medium Moderate update size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants