microsoft / microsoft/mssql-python
Bulk Copy Handles Decimal Inconsistently Compared with Normal Queries
Offen
@Theekshna arbeitet bereits daran.
Seit 02.3.2026.
area: bulk-copy
triage needed
- Vorherrschende Sprache
- Python
- Sterne
- 473
- Forks
- 60
- Ø Merge
- 2 T. 11 Std.
- Gemergte PRs (30 T.)
- 36
Beschreibung
Describe the bug
Trying to insert into a Decimal column with the new bulk_copy can throw an exception regarding mismatched decimal scale, whereas a normal insert will succeed and automatically deal with the issue. I would like to see bulk_copy work similarly and seamlessly.
To reproduce
import mssql_python
from decimal import Decimal
conn = mssql_python.connect([conn string], autocommit=True)
cur = conn.cursor()
cur.execute('create table dectest (d decimal(10, 2));')
# This next line works fine
cur.execute('insert into dectest values (?)', Decimal('123.456'))
# This line fails with the below exception
cur.bulkcopy('dectest', (Decimal('123.456'),))
Exception message
ValueError: Input decimal scale 3 exceeds target scale 2
Expected behavior
The bulkcopy should succeed and the value should be automatically rounded as it is in the insert.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.