diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-01-15 11:06:34 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-01-15 11:06:34 +0000 |
| commit | cc4e4d9aee0b3ebfb45bee01aec79edc9e144c78 (patch) | |
| tree | 2cdba846a105d406ecceff2c02e071c50502d487 /django/db/backends/oracle | |
| parent | 50a293a0c31e7325ebd520338f9c8881f951d8a7 (diff) | |
Fixed #3566 -- Added support for aggregation to the ORM. See the documentation for details on usage.
Many thanks to:
* Nicolas Lara, who worked on this feature during the 2008 Google Summer of Code.
* Alex Gaynor for his help debugging and fixing a number of issues.
* Justin Bronn for his help integrating with contrib.gis.
* Karen Tracey for her help with cross-platform testing.
* Ian Kelly for his help testing and fixing Oracle support.
* Malcolm Tredinnick for his invaluable review notes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/oracle')
| -rw-r--r-- | django/db/backends/oracle/query.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/django/db/backends/oracle/query.py b/django/db/backends/oracle/query.py index de169d6901..a86e922b95 100644 --- a/django/db/backends/oracle/query.py +++ b/django/db/backends/oracle/query.py @@ -53,21 +53,23 @@ def query_class(QueryClass, Database): return values def convert_values(self, value, field): - from django.db.models.fields import DateField, DateTimeField, \ - TimeField, BooleanField, NullBooleanField, DecimalField, Field + from django.db.models.fields import Field if isinstance(value, Database.LOB): value = value.read() # Oracle stores empty strings as null. We need to undo this in # order to adhere to the Django convention of using the empty # string instead of null, but only if the field accepts the # empty string. - if value is None and isinstance(field, Field) and field.empty_strings_allowed: + if value is None and field and field.empty_strings_allowed: value = u'' # Convert 1 or 0 to True or False - elif value in (1, 0) and isinstance(field, (BooleanField, NullBooleanField)): + elif value in (1, 0) and field and field.get_internal_type() in ('BooleanField', 'NullBooleanField'): value = bool(value) + # Force floats to the correct type + elif value is not None and field and field.get_internal_type() == 'FloatField': + value = float(value) # Convert floats to decimals - elif value is not None and isinstance(field, DecimalField): + elif value is not None and field and field.get_internal_type() == 'DecimalField': value = util.typecast_decimal(field.format_number(value)) # cx_Oracle always returns datetime.datetime objects for # DATE and TIMESTAMP columns, but Django wants to see a @@ -86,13 +88,9 @@ def query_class(QueryClass, Database): value = datetime.datetime(value.year, value.month, value.day, value.hour, value.minute, value.second, value.fsecond) - if isinstance(field, DateTimeField): - # DateTimeField subclasses DateField so must be checked - # first. - pass - elif isinstance(field, DateField): + if field and field.get_internal_type() == 'DateField': value = value.date() - elif isinstance(field, TimeField) or (value.year == 1900 and value.month == value.day == 1): + elif field and field.get_internal_type() == 'TimeField' or (value.year == 1900 and value.month == value.day == 1): value = value.time() elif value.hour == value.minute == value.second == value.microsecond == 0: value = value.date() |
