1
0
mirror of https://github.com/django/django.git synced 2025-10-15 17:59:16 +00:00

42 Commits

Author SHA1 Message Date
Malcolm Tredinnick
619576002d queyrset-refactor: Added error reporting if somebody tries to order by a multi-valued field.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7220 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-11 05:21:50 +00:00
Malcolm Tredinnick
f2f933450f queryset-refactor: Reworked exclude() handling to fix a few merging problems.
Fixed #6704.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7217 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-11 01:15:15 +00:00
Malcolm Tredinnick
fa11a6a128 queryset-refactor: Fixed a problem in the test-suite that was annoying.
Only fails on PostgreSQL and only fails on the next test.

Also identified the other area that causes both PostgreSQL backends (only) to
fail. Don't really understand why at the moment, but this is the culprit.
Tricky to reproduce, too, you have to run "queries" and "views" together, in
that order to see it.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7174 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-28 17:53:00 +00:00
Malcolm Tredinnick
33a0862215 queryset-refactor: Fixed exclude() filtering for the various N-to-many relations.
This means we can now do nested SQL queries (since we need nested queries to
get the right answer). It requires poking directly at the Query class. Might
add support for this through QuerySets later.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7170 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-28 12:57:10 +00:00
Malcolm Tredinnick
014373b459 queryset-refactor: Fixed #6664. Calling list() no longer swallows field errors.
This is slightly backwards incompatible with previous behaviour if you were
doing Tricky Stuff(tm) -- the exception type has changed if you try to create a
bad queryset.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7163 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-27 00:44:44 +00:00
Malcolm Tredinnick
3691613093 queryset-refactor: Added a test to show that #6180 is fixed. Refs #6180.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7154 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-25 06:17:16 +00:00
Malcolm Tredinnick
6ad9c684aa queryset-refactor: Implemented the reverse() method on querysets.
Refs #5012.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7148 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-23 01:35:34 +00:00
Malcolm Tredinnick
a214c6b86a queryset-refactor: Added some error checking for a potential crasher if model ordering is set up in a cycle somehow. The error reporting here isn't perfect (it doesn't give any hints about what the infinite loop might be), but it's better than nothing.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7046 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-01-28 16:08:34 +00:00
Malcolm Tredinnick
dd2251a653 queryset-refactor: Converted the queryset iterator to be a real iterator and
only populate the result cache on demand. We actually populate the result cache
100 elements at a time, rather than one at a time for efficiency, but this is a
real win when the resultset contains 10,000 objects for example.

This also provides an efficient boolean (__nonzero__) test that doesn't use up
a lot of memory if you don't read all the results.

Refs #2430, #5987.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7030 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-01-26 13:23:54 +00:00
Malcolm Tredinnick
b824d803ce queryset-refactor: Added a couple of tests to demonstrate table handling in order_by() situations. One is known to fail (and commented out for now).
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6968 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-22 11:16:21 +00:00
Malcolm Tredinnick
f47cfe12ae queryset-refactor: Tweaked one test slightly to work around a PostgreSQL oddity.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6962 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-19 13:43:16 +00:00
Malcolm Tredinnick
7292cc8d60 queryset-refactor: Reverted [6762] because it generates invalid SQL. It only worked accidentally with SQLite.
Refs #4002.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6961 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-19 13:06:45 +00:00
Malcolm Tredinnick
470ddafe97 queryset-refactor: Made qs.dates(...).count() work.
This involved a slight change in the SQL for .dates() which appears to be
correct and passes all the tests, but may have some side-effect I don't know
about.

Refs #6203.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6959 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-19 12:23:59 +00:00
Malcolm Tredinnick
18adbb6363 queryset-refactor: Fixed the way join promotions are done when joining queries (particularly the disjunctive -- 'OR' -- case). This fixes a FIXME and produces better queries.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6958 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-19 10:58:26 +00:00
Malcolm Tredinnick
519178154b queryset-refactor: Fixed a problem when adding certain additional filters to a queryset that has precisely one filter attached already.
Refs #6154.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6957 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-19 10:57:54 +00:00
Malcolm Tredinnick
13d3162aaf queryset-refactor: Added a test to show that various Q() combinations work when the same field with different lookup types are combined. Refs #4289.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-09 08:01:26 +00:00
Malcolm Tredinnick
57a4b882ae queryset-refactor: Fixed query disjunctions.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6867 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-03 21:10:51 +00:00
Malcolm Tredinnick
7b9732a4a4 queryset-refactor: Added a test for #6074 so that it gets fixed.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6859 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-03 03:31:18 +00:00
Malcolm Tredinnick
2c5373c325 queryset-refactor: Changed maxlength to max_length in a couple of tets. Silences some deprecation warnings.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6858 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-03 03:00:03 +00:00
Malcolm Tredinnick
79653a4148 queryset-refactor: Implemented filtering by output columns specified in
extra(select=...). Refs #4002.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6762 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-30 04:44:32 +00:00
Malcolm Tredinnick
b43a018032 queryset-refactor: Optimisation pass. The test suite is now within 2% of trunk and it's a fairly pathological case. Introduces a couple of test failures due to some simplification in the code. They'll be fixed later.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6730 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-29 04:56:09 +00:00
Malcolm Tredinnick
f951d97d99 queryset-refactor: Added the ability to apply parameters to the select
fragments in QuerySet.extra(). Refs #2902


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6603 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-24 04:22:23 +00:00
Malcolm Tredinnick
abcb70e524 queryset-refactor: Added a convenience all() method to Querysets. Refs #3739
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6600 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-23 13:49:07 +00:00
Malcolm Tredinnick
8c10e0d00e queryset-refactor: Fixed a possibility of shooting oneself in the foot and
creating infinite recursion with select_related(). Refs #3045, #3288.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6521 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-15 05:51:19 +00:00
Malcolm Tredinnick
44d51dae68 queryset-refactor: Added a test to show that #5261 is no longer a problem. Refs #5261.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6519 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-15 03:47:10 +00:00
Malcolm Tredinnick
70d5e32e13 queryset-refactor: Made the use of values() for ForeignKey fields consistent
and documented this feature. Refs #4358.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6516 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-15 02:54:30 +00:00
Malcolm Tredinnick
4c4341f012 queryset-refactor: Made sure the ordering columns in a distinct() query only
include the columns we are selecting on. This avoids some PostgreSQL problems
and leads to more efficient queries to boot. Refs #5321.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6515 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-15 01:20:10 +00:00
Malcolm Tredinnick
e9364c06d6 queryset-refactor: Added a test to show that #3037 is really fixed. Refs #3037.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6514 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-15 00:48:40 +00:00
Malcolm Tredinnick
05ebc901fe queryset-refactor: Fixed a couple of typos that were messing up extra(select=...).
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6512 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-15 00:29:55 +00:00
Malcolm Tredinnick
201c15dcb6 queryset-refactor: Added an order_by parameter to extra(). Refs #2076.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-15 00:29:27 +00:00
Malcolm Tredinnick
a1d160e2ea queryset-refactor: Fixed a large bag of order_by() problems.
This also picked up a small bug in some twisted select_related() handling.

Introduces a new syntax for cross-model ordering: foo__bar__baz, using field
names, instead of a strange combination of table names and field names. This
might turn out to be backwards compatible (although the old syntax leads to
bugs and is not to be recommended).

Still to come: fixes for extra() handling, since the new syntax can't handle
that and doc updates.

Things are starting to get a bit slow here, so we might eventually have to
remove ordering by many-many and other multiple-result fields, since they don't
make a lot of sense in any case. For now, it's legal.

Refs #2076, #2874, #3002 (although the admin bit doesn't work yet).


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6510 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 22:38:54 +00:00
Malcolm Tredinnick
6678de130c queryset-refactor: Fixed handling of extra(tables=...). In passing, this solves
a duplicate table / bad SQL problem. Refs #2496.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6504 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 03:46:44 +00:00
Malcolm Tredinnick
93b4199912 queryset-refactor: Added a test to show we can now query for empty reverse
relationships. Refs #2400.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6503 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 03:46:20 +00:00
Malcolm Tredinnick
ccc3a4766d queryset-refactor: Removed unneeded import.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6500 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 03:45:34 +00:00
Malcolm Tredinnick
0ebb752e89 queryset-refactor: Made all the changes needed to have count() work properly
with ValuesQuerySet. This is the general case of #2939.

At this point, all the existing tests now pass on the branch (except for
Oracle). It's a bit slower than before, though, and there are still a bunch of known bugs that aren't in the tests (or only exercised for some backends).


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6497 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 02:16:38 +00:00
Malcolm Tredinnick
240ecf0811 queryset-refactor: Fixed the optimization that potentially removes the final
join to handle the case where a to_field attribute is given for the join.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6495 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 02:15:52 +00:00
Malcolm Tredinnick
425e4662a4 queryset-refactor: Fixed the SQL construction when excluding items across
nullable joins. This is #5324 plus a few more complex variations on that theme.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6494 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 02:15:28 +00:00
Malcolm Tredinnick
142e400c5c queryset-refactor: Create a new join when merging two QuerySets that use a 1-m
field.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6492 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 02:14:53 +00:00
Malcolm Tredinnick
8926b431ed queryset-refactor: Removed a test that can be better (and simply) fixed on trunk
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6491 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 02:14:29 +00:00
Malcolm Tredinnick
2c4013e74f queryset-refactor: Fixed a problem in the isnull=True handling.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6490 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-14 02:14:15 +00:00
Malcolm Tredinnick
ff3f6df54c Fixed some more join and lookup tests.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6121 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-13 06:33:41 +00:00
Malcolm Tredinnick
2d07a19c19 Created some tests to show ORM queries that are problematic.
Still incomplete at the moment, but this version doesn't crash the test
framework.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6113 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-13 02:47:29 +00:00