Title: PostgreSQL datahandler should return Decimals instead of floats for NUMERIC/DECIMAL columns
Type: Severity: normal
Components: zxjdbc Versions: Jython 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: clach04, fwierzbicki, joseflores, leosoto, pjenvey, zyasoft
Priority: normal Keywords:

Created on 2009-11-02.00:20:13 by leosoto, last changed 2014-10-29.20:28:42 by zyasoft.

msg5296 (view) Author: Leonardo Soto (leosoto) Date: 2009-11-02.00:20:12
The current postgresql data handler does a convertion from BigDecimal to
float for DECIMAL/NUMERIC columns, which is wrong since we will likely
lost precision in the process.
msg5299 (view) Author: Leonardo Soto (leosoto) Date: 2009-11-04.01:12:44
Fixed in 6937
msg5300 (view) Author: Leonardo Soto (leosoto) Date: 2009-11-04.01:12:57
I mean, in r6937
msg5303 (view) Author: Jim Baker (zyasoft) Date: 2009-11-06.15:02:43
This might break existing code, since floats cannot be directly combined
with Decimals. So for example, I can't do this:

>>> Decimal("0.5") * 0.5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for *: 'Decimal' and 'float'

Perhaps we can make this a configuration setting in the connection?

Also, this should be applied to other data handlers like Oracle.
msg5304 (view) Author: Leonardo Soto (leosoto) Date: 2009-11-06.15:51:32
Good points. 

On the other hand, the old behavior is broken IMHO. I lean towards
giving an option for retaining the old behavior but defaulting at the
new one.
msg5305 (view) Author: Leonardo Soto (leosoto) Date: 2009-11-06.15:54:04
So, people who are using the PostgresqlDataHandler and want to retain
the old behaviour would have to do something like:

connection.datahandler = PostgresqlDataHanlder(connection.datahandler,
msg5868 (view) Author: Jose Flores (joseflores) Date: 2010-07-02.15:06:16
Hi leanardo, This also happens with MySQL (ver GA 5.1, conector/J 5.1.XX). Should we post a new ticket for it?
msg6272 (view) Author: Chris Clark (clach04) Date: 2010-12-08.00:48:39
As per joseflores update, this does not impact only Postgres as the title suggests.  This impacts generic handler ( line 254) and is probably in other handlers (like MySQL too).
msg6512 (view) Author: Philip Jenvey (pjenvey) Date: 2011-04-23.19:42:23
We should really fix this (breaking the old behavior) for all other databases, and make the behavior the default. 2.6 would be a great time to do this
msg6599 (view) Author: Chris Clark (clach04) Date: 2011-08-12.03:03:40
In case anyone else hits this I implemented a driver that returns decimal types. The driver is not by any means complete but decimals work (which was what I needed).
msg9098 (view) Author: Jim Baker (zyasoft) Date: 2014-10-06.03:28:25
Given that clach04 fixed this in jyjdbc AND we plan to switch out zxJDBC to jyjdbc for beta 4, we should have this finally fixed.
msg9184 (view) Author: Jim Baker (zyasoft) Date: 2014-10-29.20:28:34
Deferred to 2.7.1 or later
Date User Action Args
2014-10-29 20:28:42zyasoftsetpriority: high -> normal
2014-10-29 20:28:34zyasoftsetmessages: + msg9184
2014-10-06 03:28:26zyasoftsetassignee: fwierzbicki
messages: + msg9098
2013-02-26 17:27:14fwierzbickisetnosy: + fwierzbicki
2013-02-25 18:37:41fwierzbickisetassignee: leosoto -> (no value)
2013-02-25 18:37:26fwierzbickisetpriority: high
versions: + Jython 2.7, - 2.5.1
2011-08-12 03:03:40clach04setmessages: + msg6599
2011-04-23 19:42:24pjenveysetnosy: + pjenvey
messages: + msg6512
2010-12-08 00:48:40clach04setnosy: + clach04
messages: + msg6272
2010-07-02 15:06:17josefloressetnosy: + joseflores
messages: + msg5868
2009-11-06 15:54:05leosotosetmessages: + msg5305
2009-11-06 15:51:32leosotosetmessages: + msg5304
2009-11-06 15:02:44zyasoftsetnosy: + zyasoft
messages: + msg5303
2009-11-04 01:12:57leosotosetmessages: + msg5300
2009-11-04 01:12:44leosotosetmessages: + msg5299
2009-11-02 00:20:13leosotocreate