Issue 71 in django-jython: DecimalField doesn't round to decimal_places when save to db with doj.backends.zxjdbc.postgresql ENGINE

52 views
Skip to first unread message

django...@googlecode.com

unread,
Feb 13, 2012, 2:47:10 PM2/13/12
to django-j...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 71 by my...@adconion.com: DecimalField doesn't round to
decimal_places when save to db with doj.backends.zxjdbc.postgresql ENGINE
http://code.google.com/p/django-jython/issues/detail?id=71

What steps will reproduce the problem?
1. Use "doj.backends.zxjdbc.postgresql" as database engine

In settings.py

DATABASES = {
'default': {
'ENGINE': 'doj.backends.zxjdbc.postgresql',
'NAME': '',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
2. Create a Django model with DecimalField

class A(models.Model):
revenue = models.DecimalField(max_digits=10, decimal_places=4)

3. Set revenue for a A record and save into database
a = A()
a.revenue = 1.234567
a.save()

What is the expected output? What do you see instead?

For revenue column in database:
- Expected output: 1.2346 (rounded to 4 decimal places)
- Actual output: 1.234567 (not rounded)

What version of the product are you using? On what operating system?

jython: 2.5.2
django-jython: 1.3.0b1
OS: Max OS X 10.5.8

Please provide any additional information below.

django / db / models / base.py (save_base method)
- Django rounds DecimalField value using field.get_db_prep_save(value) to
get value to save into db.

django / db / models / fields / __init__.py (DecimalField class)
- In get_db_prep_save() , connection.ops.value_to_db_decimal(value,
max_digits, decimal_places) is called to round value of Decimal Field.

## Use psycopg_postgres as engine
django / db / backends / postgres / operations.py (DatabaseOperations class)
- connection.ops delegates to DatabaseOperations class which uses
value_to_db_decimal() method from parent class BaseDatabaseOperations.

## Use zxjdbc as engine
django-jython / doj / backends / zxjdbc / postgresql / base.py
(DatabaseOperations class)
- connection.ops delegates to DatabaseOperations which inherit
zxJDBCOperationsMixin and PostgresqlDatabaseOperations, but it uses
value_to_db_decimal() method from zxJDBCOperationsMixin which simply just
return value without rounding.


Let me know if there is any part not clear or any wrong information.


django...@googlecode.com

unread,
Oct 7, 2012, 10:22:59 AM10/7/12
to django-j...@googlegroups.com
Updates:
Owner: juneau001

Comment #1 on issue 71 by juneau001: DecimalField doesn't round to
decimal_places when save to db with doj.backends.zxjdbc.postgresql ENGINE
http://code.google.com/p/django-jython/issues/detail?id=71

(No comment was entered for this change.)

django...@googlecode.com

unread,
Aug 10, 2014, 4:27:29 AM8/10/14
to django-j...@googlegroups.com
Updates:
Status: Fixed

Comment #2 on issue 71 by andr...@st0cker.at: DecimalField doesn't round to
decimal_places when save to db with doj.backends.zxjdbc.postgresql ENGINE
http://code.google.com/p/django-jython/issues/detail?id=71

(No comment was entered for this change.)

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages