FEAT: Adding money and smallmoney support in executemany by gargsaumya · Pull Request #246 · microsoft/mssql-python

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.