Malcolm Tredinnick
bb132aa395
queryset-refactor: Repaired the dates() method with extra(select=...).xi
...
It was broken by [7340]. Patch from Ian Kelly. Fixed #7087 .
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7468 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-26 09:06:56 +00:00
Malcolm Tredinnick
caa150e45e
queryset-refactor: Fixed some bugs in the multi-valued filtering behaviour
...
introduced in [7317]. It was failing in a couple of different ways on some
complex Q() combinations.
Fixed #7047
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7462 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-25 17:08:28 +00:00
Malcolm Tredinnick
8a4e1de8b0
queryset-refactor: Changed the way order_by() and distinct() interact.
...
When using "select distinct" all ordering columns must be part of the output
(select) columns. We were previously just throwing away ordering columns that
weren't included, but there are some cases where they are needed and it's
difficult to add them in manually. So now the default behaviour is to append
any missing columns.
This can affect the output of distinct() if complicated order_by() constructs
are used, so the documentation has been updated with an explanation of what's
going on there.
Fixed #7070 .
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7455 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-24 16:07:07 +00:00
Malcolm Tredinnick
19d6bc7acd
queryset-refactor: Fixed a crash when using extra(tables=...). Fixed #7045 .
...
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7447 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-23 10:43:42 +00:00
Malcolm Tredinnick
0a66eabc8a
queryset-refactor: Made on of the tests use more portable SQL to help Oracle.
...
Patch from Ian Kelly. Fixed #7058 .
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-22 18:10:12 +00:00
Malcolm Tredinnick
36bbebc739
queryset-refactor: Detect infinite ordering loops when relations refer to 'self'.
...
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7429 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-16 04:32:56 +00:00
Malcolm Tredinnick
01b7a16ef0
queryset-refactor: When using select_related() with an explicit foreign key,
...
use the right join type if the FK is nullable. Fixed #6981 .
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7418 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-13 04:42:08 +00:00
Malcolm Tredinnick
ed23f00a00
Fixed #6899 -- Fixed a problem with boolean evaluation of empty querysets.
...
Based on patches from cide@ctmod.net and brodie.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7417 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-13 03:22:38 +00:00
Malcolm Tredinnick
04da22633f
queryset-refactor: Fixed up extra(select=...) calls with parameters so that the
...
parameters are substituted in correctly in all cases. This introduces an extra
argument to extra() for this purpose; no alternative there.
Also fixed values() to work if you don't specify *all* the extra select aliases
in the values() call.
Refs #3141 .
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7340 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-20 19:16:04 +00:00
Malcolm Tredinnick
d20996b58d
queryset-refactor: Implemented a way to differentiate between filtering on a
...
single instance and filtering on multiple instances when spanning a
multi-valued relationship.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7317 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-19 11:02:22 +00:00
Malcolm Tredinnick
67cc3cec90
queryset-refactored: Added a test to show that ordering on multi-valued fields
...
might not be what is expected.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7286 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-18 10:33:37 +00:00
Malcolm Tredinnick
670be13986
queryset-refactor: Undo [7220] and allow ordering on multi-valued field.
...
Some people will shoot themselves in the foot with this. That's bad luck.
The reason we need it is because some data semantics cannot be expressed in
Django's ORM and that shouldn't prevent ordering on that data. For example,
filtering suburbs by a geographic region and then ordering on the suburb names.
The names might not be unique outside that region, but unique inside it. Django
cannot know that (you can't tell the model about it), so we trust the caller.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7285 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-18 10:21:50 +00:00
Malcolm Tredinnick
93baa3e417
queryset-refactor: Optimised some internal data structures in sql/query.py.
...
Mostly this involves changing them to a "copy on write" implementation, which
speeds up cloning (and the relevant structures aren't updated very frequently).
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7247 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-15 09:13:22 +00:00
Malcolm Tredinnick
f3ed30f377
queryset-refactor: Infinite loop detection in model ordering was being a little
...
too aggressive. Fixed that.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7224 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-11 08:23:51 +00:00
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