Closed GoogleCodeExporter closed 9 years ago
OK I did some debugging work. It looks like the problem is in src/params.cpp
at line
644 (in v. 2.1.7) where it sets cbColDef, the ColumnSize parameter to
SQLBindParameter.
It's setting the ColumnSize to simply the length of the string representation
of the
number. The problem is that it's including the decimal point, and the negative
sign
for negative numbers. This results in a too-long ColumnSize. E.g. if you pass
a 38
decimal digit negative number, ColumSize becomes 40, and SQL Server only allows
38
precision. Thus the error. The solution seems to be to not include the decimal
and
negative sign (if any) in the ColumnSize.
Attached is a patch which does that and an updated version of that unit test
that
demonstrates the fix and also tests a negative number and a number with
scale=0. I
imagine the actual patch would need to be cleaned up before being committed.
For one
thing, I'm not sure how kosher it is to directly check the _sign attribute of
Decimal
numbers, as opposed to calling is_signed(). Also I'd suggest adding
representative
test cases to the pyodbc project unit tests.
Hope this helps.
Original comment by pland...@gmail.com
on 27 Feb 2010 at 6:08
Attachments:
Thanks for the patch. I'll add the unit tests as you suggest (always a good
idea) and apply the patch to 2.1.8, due very soon.
Original comment by mkleehammer
on 24 Aug 2010 at 4:07
Fixed in the v2unicode branch, which will become 2.1.8 as soon as I'm sure it
is ready. Thanks again.
Original comment by mkleehammer
on 5 Sep 2010 at 6:19
Fixed in 2.1.8
Original comment by mkleehammer
on 6 Sep 2010 at 5:38
Original comment by mkleehammer
on 21 Nov 2010 at 4:44
Original issue reported on code.google.com by
pland...@gmail.com
on 26 Feb 2010 at 10:09Attachments: