-
Notifications
You must be signed in to change notification settings - Fork 27
FEAT: Adding money and smallmoney support in executemany #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
executemanyparameter 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.
sumitmsft
left a comment
There was a problem hiding this 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..
sumitmsft
left a comment
There was a problem hiding this 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.
Work Item / Issue Reference
Summary
This pull request improves the handling of
decimal.Decimalvalues andNone(NULL) values when usingexecutemanyto 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:cursor.pyto ensure thatdecimal.Decimalvalues are properly converted for VARCHAR columns and thatNonevalues 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:
test_money_smallmoney_roundtrip_executemanyto verify that inserting and retrieving MONEY and SMALLMONEY values usingexecutemanywithdecimal.Decimalworks as expected, including checks for value equality and type.test_money_smallmoney_executemany_null_handlingto ensure that inserting NULLs into MONEY and SMALLMONEY columns viaexecutemanybehaves correctly and returns the expected results.