Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Results for Int data #42

Closed
detroitcoder opened this issue Apr 28, 2015 · 2 comments
Closed

Incorrect Results for Int data #42

detroitcoder opened this issue Apr 28, 2015 · 2 comments

Comments

@detroitcoder
Copy link

A select query of integer data returns incorrect results when I am running pyodbc 3.0.7 with python 2.7 on RHEL6 against a Sybase database. I do not experience this issue when running on 3.0.3

Here is a basic example of incorrect results for int data

import pyodbc
dbconn = pyodbc.connect("DSN=....")
c = dbconn.cursor()
c.execute("select 0, 1, 2")
print c.fetchone()

>> (210453397504, 210453397505, 210453397506)

All of the integers consistently add 2^32 * 2^7 (210453397504) to the correct value. This remains true until the value gets to 2^31 (2147483648), at which point results are correctly converted to type Long.

When I explicitly cast the data to numeric, it returns correctly:

c.execute("select cast(0 as numeric), cast(1 as numeric), cast(2 as numeric)")
print c.fetchone()

>> (Decimal('0'), Decimal('1'), Decimal('2'))

Likewise if I explicitly add a decimal to the values, it will return the correct values as Decimal instances

c.execute("select 0.0, 1.0, 2.0")

>> (Decimal('0'), Decimal('1'), Decimal('2'))

However when I try to cast the data as Ints, I get the same incorrect results as I do by default:

c.execute("select cast(0 as int), cast(1 as int), cast(2 as int)")
print c.fetchone()

>> (210453397504, 210453397505, 210453397506)

There are a couple other users that have experienced the same issue on code.google.com
https://code.google.com/p/pyodbc/issues/detail?id=360

@mkleehammer
Copy link
Owner

Finally confirmed - I had to rebuild a new test VM.

@mkleehammer
Copy link
Owner

git bisect points finger at 916c69e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants