zillow / ctds

Python DB-API 2.0 library for MS SQL Server
MIT License
83 stars 12 forks source link

Fix data truncation in executemany #26

Closed joshuahlang closed 6 years ago

joshuahlang commented 6 years ago

Data truncation can occur when multiple parameter sequences are passed to executemany and the first sequence contains values that map to variable length SQL types. The width of the SQL type is determined by the values in the first sequence, so if these are shorter than values in subsequent parameter sequences to the values are truncated. This is due to the implementation of executemany, which uses sp_executesql internally and must declare the type of the parameter before the first execution.