Skip to content

Conversation

@gargsaumya
Copy link
Contributor

@gargsaumya gargsaumya commented Sep 19, 2025

Work Item / Issue Reference

AB#34936
AB#34937

GitHub Issue: #<ISSUE_NUMBER>


Summary

This pull request improves the handling of decimal.Decimal values and None (NULL) values when using executemany to insert data into MONEY and SMALLMONEY columns in SQL Server. It also adds comprehensive tests to verify correct roundtrip and NULL handling for these types.

Improvements to parameter processing in executemany:

  • Updated the parameter processing logic in cursor.py to ensure that decimal.Decimal values are properly converted for VARCHAR columns and that None values are correctly skipped during conversion. This helps prevent type errors and ensures correct database insertion for MONEY, SMALLMONEY, and related types.

Expanded test coverage for MONEY and SMALLMONEY types:

  • Added test_money_smallmoney_roundtrip_executemany to verify that inserting and retrieving MONEY and SMALLMONEY values using executemany with decimal.Decimal works as expected, including checks for value equality and type.
  • Added test_money_smallmoney_executemany_null_handling to ensure that inserting NULLs into MONEY and SMALLMONEY columns via executemany behaves correctly and returns the expected results.

Copilot AI review requested due to automatic review settings September 19, 2025 09:22
@github-actions github-actions bot added the pr-size: small Minimal code update label Sep 19, 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 PR adds support for handling decimal.Decimal and None values in MONEY and SMALLMONEY columns when using executemany. The changes improve parameter processing to correctly convert decimal values and skip null values during type conversion.

  • Enhanced executemany parameter processing to handle decimal values for VARCHAR columns (money/smallmoney) and properly skip None values
  • Added comprehensive test coverage for money/smallmoney roundtrip operations and null handling with executemany

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
mssql_python/cursor.py Updated parameter processing logic in executemany to handle decimal conversion for VARCHAR columns and skip None values
tests/test_004_cursor.py Added two new test functions to verify money/smallmoney roundtrip behavior and null handling with executemany

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

Added a small comment..

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.

Please add a few test cases. Rest all looks good to me.

@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: small Minimal code update labels Sep 24, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 24, 2025
@github-actions github-actions bot added pr-size: medium Moderate update size and removed pr-size: medium Moderate update size labels Sep 24, 2025
@gargsaumya gargsaumya merged commit 5d50020 into main Sep 24, 2025
18 checks passed
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