FEAT: Adding money and smallmoney support in executemany by gargsaumya · Pull Request #246 · microsoft/mssql-python
Work Item / Issue Reference
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.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:
- Added
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. - Added
test_money_smallmoney_executemany_null_handlingto ensure that inserting NULLs into MONEY and SMALLMONEY columns viaexecutemanybehaves correctly and returns the expected results.