On Wed, Jan 7, 2009 at 8:55 AM, Karen Tracey <kmtra...@gmail.com> wrote:
> On Wed, Jan 7, 2009 at 9:46 AM, Russell Keith-Magee <freakboy3...@gmail.com>
> wrote:
>>
>> I've just pushed some updates to Github that should hopefully fix the
>> problems that have been reported (ORA-00933, ORA-00923 and ORA-00972
>> and the decimal/datetime conversion problems). If someone with access
>> to an Oracle test machine can confirm that this has cleaned up the
>> errors, I'd be much obliged.
>
> The aggregation tests now pass.  aggregation_regress has one (minor?)
> problem:
>
> Doctest: regressiontests.aggregation_regress.models.__test__.API_TESTS ...
> FAIL
>
> ======================================================================
> FAIL: Doctest: regressiontests.aggregation_regress.models.__test__.API_TESTS
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "d:\u\kmt\django\aggregates.git\django\test\_doctest.py", line 2180,
> in runTest
>     raise self.failureException(self.format_failure(new.getvalue()))
> AssertionError: Failed doctest test for
> regressiontests.aggregation_regress.models.__test__.API_TESTS
>   File
> "D:\u\kmt\django\aggregates.git\tests\regressiontests\aggregation_regress\models.py",
> line unknown line number, in API_TESTS
>
> ----------------------------------------------------------------------
> File
> "D:\u\kmt\django\aggregates.git\tests\regressiontests\aggregation_regress\models.py",
> line ?, in regressiontests.aggregation_regress.models.__test__.API_TESTS
> Failed example:
>
> Publisher.objects.annotate(avg_price=Avg('book__price')).aggregate(Max('avg_price'))
> Expected:
>     {'avg_price__max': 75.0...}
> Got:
>     {'avg_price__max': 75}
>
>
> ----------------------------------------------------------------------
> Ran 1 test in 11.757s
>
> FAILED (failures=1)
> Destroying test database...

This appears to be an existing problem in the Oracle backend where
convert_values neglects to convert FloatField values (interesting that
nothing else in the test suite catches this).  But is there a reason
that the aggregation field returns an internal type of FloatField when
the field was originally a DecimalField?

Another oddity with this query is that removing the aggregate call
from the above query and leaving only the annotate still results in
floats instead of decimals.  It appears that ops.convert_values isn't
getting called in that case.  But replace Avg with Max or Sum and it
does get called.

I noticed another bug while testing this: the annotate query above is
modified after the aggregate call, which can be observed by the
following code.  I don't think this one is related to the Oracle
backend.

>>> qs = Publisher.objects.annotate(avg_price=Avg('book__price'))
>>> qs.query.as_sql()
>>> qs.aggregate(Max('avg_price'))
>>> qs.query.as_sql()

Ian

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to