Bug 719093 - set_decimal not honored
Summary: set_decimal not honored
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: PyGreSQL
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tom Lane
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-05 18:30 UTC by Mike McLean
Modified: 2013-07-03 03:37 UTC (History)
3 users (show)

Fixed In Version: PyGreSQL-4.0-3.fc15
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-16 07:26:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.