I have now finished work on ticket #3566 - adding aggregations to Django's ORM.
I intend to commit the code to Django's trunk tomorrow evening, my
time (i.e., in about 30 hours time).
If you have any objections or problem reports, speak now or live with
the consequences :-)
Yours,
Russ Magee %-)
Woohoo! Congratulations, and many thanks to you, Nicolas, and all the
others who helped out.
Jacob
If you have any objections or problem reports, speak now or live with
the consequences :-)
I'm seeing the same errors using the tarball snapshot. All but the
last one are fixed by the attached patch.
Ian
By "the last one" I actually mean the final failure where a float is
expected but an int is seen.
Ian
On Wed, Jan 14, 2009 at 3:54 PM, Karen Tracey <kmtr...@gmail.com> wrote:
>
> I'm getting some errors running the aggregation and aggregation_regress
> tests on Windows boxes running Python 2.5.2 and 2.5.4 when using sqlite as
> the database.� I do not see these failures on these boxes using 'sqlite3'
> backend and Python 2.3.5, 2.4.4 or 2.6/2.6.1, nor on a Linux box with Python
> 2.5.1.� The errors can be seen here (the failures are the same for 2.5.2 and
> 2.5.4):
>
> http://dpaste.com/109020/
I will be able to test this by myself in a couple of hours, but just in
case you have the Windows system with at hand, what are the versions of
SQLlite and pysqlite2 (aka sqlite3) included in the official win32 2.5.4
binaries?:
>>> from sqlite3 import dbapi2
>>> print dbapi2.version_info
...
>>> print dbapi2.sqlite_version_info
...
Regards,
--
Ramiro Morales
Thanks for the patch, Ian. The patch applied cleanly; I've applied it
and pushed it upstream.
Russ %-)
I will now say a word that is not sanctioned by the church for use in public.
....
Now that I have that out of my system... :-)
Ok, this is wierd. The errors you are reporting are exactly what I
would expect to see if the SQLite specific convert_values() function
wasn't getting called. Given your reported problems with git, can you
confirm that on the failing box:
1) django.db.backends.__init__.py lines 386:399 defines a
convert_values(self, values, field) function,
2) django.db.backends.sqlite3.base.py lines 105:123 has a
convert_values(self, values, field) function,
3) the backend specific version of the convert_values function that
is being invoked in your running test case.
If the backend specific version is getting used, can you have a quick
poke around to see any reason why, for example, the first failing test
has decimal and date values, but the field types aren't invoking the
date/decimal specific type conversions.
Russ %-)
Can you (or Karen) confirm if the following patch:
cleans up this issue?
Yours,
Russ Magee %-)
Almost. It chokes on None values. Add a check for that, and it works.
Ian
I will now say a word that is not sanctioned by the church for use in public.
On Thu, Jan 15, 2009 at 2:54 AM, Karen Tracey <kmtr...@gmail.com> wrote:
> On Tue, Jan 13, 2009 at 10:52 PM, Russell Keith-Magee
> <freakb...@gmail.com> wrote:
>>
>> If you have any objections or problem reports, speak now or live with
>> the consequences :-)
>
> I'm getting some errors running the aggregation and aggregation_regress
> tests on Windows boxes running Python 2.5.2 and 2.5.4 when using sqlite as
> the database. I do not see these failures on these boxes using 'sqlite3'
> backend and Python 2.3.5, 2.4.4 or 2.6/2.6.1, nor on a Linux box with Python
> 2.5.1. The errors can be seen here (the failures are the same for 2.5.2 and
> 2.5.4):
>
> http://dpaste.com/109020/
....
Now that I have that out of my system... :-)
Ok, this is wierd. The errors you are reporting are exactly what I
would expect to see if the SQLite specific convert_values() function
wasn't getting called. Given your reported problems with git, can you
confirm that on the failing box:
1) django.db.backends.__init__.py lines 386:399 defines a
convert_values(self, values, field) function,
2) django.db.backends.sqlite3.base.py lines 105:123 has a
convert_values(self, values, field) function,
3) the backend specific version of the convert_values function that
is being invoked in your running test case.
Fantastic. Done, and pushed to github.
Thanks Ian,
Russ %-)
Help, yes. Illuminating, No. :-(
To fill you in on what I'm looking for - every aggregate value coming
back from the database passes through resolve_aggregates() in
django.db.models.query.py (line 212). This passes to convert_values()
in query.py, which in turn defers to the backend to do conversion.
MySQL and Postgres use the base backend implementation of
convert_values(), in the base connection's __init__.py; SQLite uses an
overridden version. The errors you are seeing are consistent with data
that is passing through the base convert_values(), rather than the
specific version().
Could you please trace one of the failing queries and confirm which
backend convert_values() is being invoked for Decimal and Date fields?
If the base implementation is being invoked, can you identify any
reason why self.connection.ops isn't the SQLite specific version? If
convert_values() isn't being invoked, which branch is which the
resolve_aggregates() returning on?
Apologies for throwing you in at the deep end here - unfortunately, I
have no access to a Windows box I can test with.
Thanks,
Russ %-)
Help, yes. Illuminating, No. :-(
To fill you in on what I'm looking for - every aggregate value coming
back from the database passes through resolve_aggregates() in
django.db.models.query.py (line 212). This passes to convert_values()
in query.py, which in turn defers to the backend to do conversion.
MySQL and Postgres use the base backend implementation of
convert_values(), in the base connection's __init__.py; SQLite uses an
overridden version. The errors you are seeing are consistent with data
that is passing through the base convert_values(), rather than the
specific version().
Could you please trace one of the failing queries and confirm which
backend convert_values() is being invoked for Decimal and Date fields?
If the base implementation is being invoked, can you identify any
reason why self.connection.ops isn't the SQLite specific version? If
convert_values() isn't being invoked, which branch is which the
resolve_aggregates() returning on?
... and finally, Russell looks closer at the output and notices the
obvious... the problem values aren't aggregates.
So, either the aggregates processing has broken the normal value
coercion, or normal value coercion has always been busted on that
combination.
Here's the check - what do you get as output for:
Book.objects.filter(pk=1).values()
on a vanilla (non-aggregates) checkout of trunk?
Russ %-)
Next suggestion is to check if the converters that are registered on
lines 38-45 of db.backends.sqlite3.base.py are actually getting
called, and if there is a difference between the pre and post resolved
versions of row in results_iter() (i.e., the value of row at lines
240, 250 and 259 of query.py).
I can't think of any reason that these converters would be disabled by
the call to aggregates, though.
Russ %-)
This is correct. resolve_columns() is an extension point used by
subclasses such as the Oracle and GIS backends. It isn't used for
other databases - hence the 'hasattr' check.
Russ %-)
Just a wild stab in the dark - but this isn't a case sensitivity
thing, is it? I noticed that there are two entries for timestamp - one
is fully capitalized. Is it possible that the backend is returning a
different capitalization once aggregates get involved? I have no idea
why this would be happening, or how you would check this at a lower
level, though - can you get Can you find out the database datatype
from the cursor?
Russ %-)
Agreed. I'll commit tonight, as originally planned.
Russ %-)