Bug 719093

Summary: set_decimal not honored
Product: [Fedora] Fedora Reporter: Mike McLean <mikem>
Component: PyGreSQLAssignee: Tom Lane <tgl>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: cito, hhorak, tgl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: PyGreSQL-4.0-3.fc15 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-16 07:26:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mike McLean 2011-07-05 18:30:07 UTC
Description of problem:
the set_decimal function is not honored by the pg libs
Consider the following:
>>> pgdb.decimal_type()
<type 'float'>
>>> c.execute('select 1.1')
>>> c.fetchall()
[[Decimal('1.1')]]
>>> pgdb.decimal_type()
<type 'float'>
>>> pgdb.Decimal
<type 'float'>

Version-Release number of selected component (if applicable):
PyGreSQL-4.0-2.fc15.x86_64
  
Actual results:
numeric values are returned as Decimal() values rather than floats, despite explicitly setting the "decimal type"

Expected results:
pgdb should honor the set_decimal setting
(also, using Decimal by default is kind of crazy and is going to break tons of code, but it would be nice if at least the lib would honor this setting so that the workaround is less painful.)


Additional info:
note that a Decimal is hardly a drop-in replacement for a float.
>>> Decimal(1.1)/1.0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for /: 'Decimal' and 'float'

Comment 1 Tom Lane 2011-07-05 20:25:52 UTC
Reported upstream at http://mailman.vex.net/pipermail/pygresql/2011-July/002410.html

Comment 2 Cito 2011-07-07 18:26:59 UTC
Fixed in the PyGreSQL trunk now, see
http://trac.vex.net:8000/pgtracker/ticket/38

Comment 3 Fedora Update System 2011-07-08 00:44:16 UTC
PyGreSQL-4.0-3.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/PyGreSQL-4.0-3.fc15

Comment 4 Tom Lane 2011-07-08 00:46:23 UTC
I'm not enough of a Python user to verify whether this patch does what you want, so please check it.

Comment 5 Fedora Update System 2011-07-08 18:01:08 UTC
Package PyGreSQL-4.0-3.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing PyGreSQL-4.0-3.fc15'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/PyGreSQL-4.0-3.fc15
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2011-07-16 07:26:21 UTC
PyGreSQL-4.0-3.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.