mirror of
https://github.com/django/django.git
synced 2025-07-05 02:09:13 +00:00
boulder-oracle-sprint: Made Oracle return DecimalField values as decimal objects.
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5309 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
97ccb9304e
commit
12b5df62dd
@ -461,7 +461,7 @@ def get_query_set_class(DefaultQuerySet):
|
|||||||
|
|
||||||
def resolve_columns(self, row, fields=()):
|
def resolve_columns(self, row, fields=()):
|
||||||
from django.db.models.fields import DateField, DateTimeField, \
|
from django.db.models.fields import DateField, DateTimeField, \
|
||||||
TimeField, BooleanField, NullBooleanField
|
TimeField, BooleanField, NullBooleanField, DecimalField
|
||||||
values = []
|
values = []
|
||||||
for value, field in map(None, row, fields):
|
for value, field in map(None, row, fields):
|
||||||
if isinstance(value, Database.LOB):
|
if isinstance(value, Database.LOB):
|
||||||
@ -475,6 +475,9 @@ def get_query_set_class(DefaultQuerySet):
|
|||||||
# Convert 1 or 0 to True or False
|
# Convert 1 or 0 to True or False
|
||||||
elif value in (1, 0) and isinstance(field, (BooleanField, NullBooleanField)):
|
elif value in (1, 0) and isinstance(field, (BooleanField, NullBooleanField)):
|
||||||
value = bool(value)
|
value = bool(value)
|
||||||
|
# Convert floats to decimals
|
||||||
|
elif value is not None and isinstance(field, DecimalField):
|
||||||
|
value = util.typecast_decimal(field.format_number(value))
|
||||||
# cx_Oracle always returns datetime.datetime objects for
|
# cx_Oracle always returns datetime.datetime objects for
|
||||||
# DATE and TIMESTAMP columns, but Django wants to see a
|
# DATE and TIMESTAMP columns, but Django wants to see a
|
||||||
# python datetime.date, .time, or .datetime. We use the type
|
# python datetime.date, .time, or .datetime. We use the type
|
||||||
|
@ -211,7 +211,8 @@ class Model(object):
|
|||||||
if pk_set:
|
if pk_set:
|
||||||
# Determine whether a record with the primary key already exists.
|
# Determine whether a record with the primary key already exists.
|
||||||
cursor.execute("SELECT COUNT(*) FROM %s WHERE %s=%%s" % \
|
cursor.execute("SELECT COUNT(*) FROM %s WHERE %s=%%s" % \
|
||||||
(backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), [pk_val])
|
(backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)),
|
||||||
|
self._meta.pk.get_db_prep_lookup('exact', pk_val))
|
||||||
# If it does already exist, do an UPDATE.
|
# If it does already exist, do an UPDATE.
|
||||||
if cursor.fetchone()[0] > 0:
|
if cursor.fetchone()[0] > 0:
|
||||||
db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks]
|
db_values = [f.get_db_prep_save(f.pre_save(self, False)) for f in non_pks]
|
||||||
@ -220,7 +221,7 @@ class Model(object):
|
|||||||
(backend.quote_name(self._meta.db_table),
|
(backend.quote_name(self._meta.db_table),
|
||||||
','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks]),
|
','.join(['%s=%%s' % backend.quote_name(f.column) for f in non_pks]),
|
||||||
backend.quote_name(self._meta.pk.column)),
|
backend.quote_name(self._meta.pk.column)),
|
||||||
db_values + [pk_val])
|
db_values + self._meta.pk.get_db_prep_lookup('exact', pk_val))
|
||||||
else:
|
else:
|
||||||
record_exists = False
|
record_exists = False
|
||||||
if not pk_set or not record_exists:
|
if not pk_set or not record_exists:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user