1
0
mirror of https://github.com/django/django.git synced 2025-07-05 18:29:11 +00:00

4060 Commits

Author SHA1 Message Date
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
8b52e8e40e queryset-refactor: Removed the facility for select_related(False). It was
useless.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7284 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-18 10:21:12 +00:00
Malcolm Tredinnick
98b5667a06 queryset-refactor: Different database backends return different empty sequences
when fetchmany() is exhausted. This change allows for that. Fixed #6807.

Nice debugging from tpherndon.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7283 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-18 06:15:29 +00:00
Malcolm Tredinnick
6b974720a9 queryset-refactor: Typo fix. Fixed #6806.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7282 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-18 06:14:56 +00:00
Malcolm Tredinnick
6df9e25b61 queryset-refactor: Merged from trunk up to [7280]
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7281 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-18 05:45:37 +00:00
Malcolm Tredinnick
133111e40b queyrset-refactor: Some more speed-ups due to datastructure changes.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7255 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-17 13:32:11 +00:00
Malcolm Tredinnick
067d380e98 queryset-refactor: More whack-a-mole optimisation work. Still got a couple of big spots to go, though.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7253 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-16 16:18:39 +00:00
Malcolm Tredinnick
50a1880100 queryset-refactor: Typo fix.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7252 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-16 16:17:57 +00:00
Malcolm Tredinnick
0c84766c58 queryset-refactor: Fixed a typo spotted by msaelices. Fixed #6787.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7250 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-16 01:20:51 +00:00
Malcolm Tredinnick
b102bf28b9 queryset-refactor: Optimised the SQL portion of Model.save().
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7249 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-15 14:16:05 +00:00
Malcolm Tredinnick
ade818fd7d queryset-refactor: Sped up QuerySet.get() by using fast paths through the iterator maze.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7248 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-15 14:15:43 +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
7534ef1f7e queryset-refactor: Optimised len(qs) and iter(qs) a bit.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7246 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-15 09:12:44 +00:00
Malcolm Tredinnick
d08ec81228 queryset-refactor: The EmptyResultSet exception was declared in two places.
Removed one of them.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7245 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-15 02:25:46 +00:00
Malcolm Tredinnick
a81813fb4a queryset-refactor: Fixed the "in" lookup type when using tuples.
Accidentally broken in r7170. Fixed #6772.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7244 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-15 01:59:06 +00:00
Malcolm Tredinnick
2f45deb72c queryset-refactor: Some goose left commented out code in [7240]. Nothing to see here. Move along.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7242 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-14 11:49:31 +00:00
Malcolm Tredinnick
59ac04a54d queryset-refactor: Second part of select_related() fix.
Relations on the parent model can now be specified as part of the fields list.
Fixed #6761.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-14 11:46:26 +00:00
Malcolm Tredinnick
cf2da4689a queryset-refactor: Fixed default (no fields) case of select_related() to work with model inheritance. Refs #6761.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7240 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-14 11:45:52 +00:00
Malcolm Tredinnick
d91479a287 queryset-refactor: Changed the return type of an internal function.
Previous polymorphic return type was dumb.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7235 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-13 11:48:25 +00:00
Malcolm Tredinnick
53634d4cdd queryset-refactor: Made sure that update filter queries only return a single
column. Fixed #6760.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7234 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-13 10:46:54 +00:00
Malcolm Tredinnick
9f0fb3dcc9 queryset-refactor: Made none() a method on Querysets, as the documentation
indicates (it was only added to managers in [4394]. Refs #6177.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7232 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-13 00:36:57 +00:00
Malcolm Tredinnick
c8b33b824b queryset-refactor: Added a way to change the prefix of all aliases in a query.
This fixes the last few corner cases for nested queries that had overlapping
aliases. Also tidies up a couple of internal data structures.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7231 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-12 14:52:12 +00:00
Malcolm Tredinnick
428450b7a9 queryset-refactor: Refactored the way values() works so that it works properly
across inherited models.

Completely by accident, this also allows values() queries to include fields
from related models, providing it is crossing a single-valued relation
(one-to-one, many-to-one). Many-to-many values() fields still aren't supported,
since that requires actual thinking. So this refs #5768.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7230 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-12 12:41:58 +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
3176bebffd queryset-refactor: Reorganised Model.save() to differentiate between public and private parameters. Refs #6741.
This means subclasses can override save() without needing to worry about
passing around the internal parameters (an issue for subclassable models, which
would have meant every model, since you don't know when somebody will subclass
your model).

Slightly backwards incompatible, since it moves "raw" back to being part of the
internal API (it's only needed by the serializer and was intended to be
internal use only). If external code really needs this, they can call
Model.save_base() and pass in raw there.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7221 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-11 05:36:10 +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
62bdb6eae8 queryset-refactor: Merged from trunk up to [7216].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7219 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-11 03:15:07 +00:00
Malcolm Tredinnick
df8e3e6512 queryset-refactor: Fixed an oversight in Model.save() that was preventing updates to parent models beyond the initial save. Fixed #6706.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7218 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-11 02:48:39 +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
d4d528e9b0 queryset-refactor: Simplified updates of related tables, with added bonus of less bugs.
It will be slightly less efficient in rare cases, but who cares? If anybody
needs it to be as efficient as possible they can write the query manually and
this is good enough for the other 98% or so.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7190 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-03-03 16:36:28 +00:00
Malcolm Tredinnick
22ecacda1b queryset-refactor: Fixed a small error in [7179].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7180 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-29 15:58:39 +00:00
Malcolm Tredinnick
2f8f588df1 queryset-refactor: Made update() work with inherited models.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7179 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-29 15:53:25 +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
2f2908d7b5 queryset-refactor: Merged from trunk up to [7168].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7173 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-28 15:48:19 +00:00
Malcolm Tredinnick
7c54780497 queryset-refactor: Head off any attempts to use unique_together across inherited models.
We don't support check constraints and triggers, so trying to do this would be
optimistic at best.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7172 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-28 13:31:11 +00:00
Malcolm Tredinnick
a9008f8928 queryset-refactor: Added caching for reverse-one-to-one lookups.
This is the only type of reverse lookup where caching makes sense might make
some kinds of model inheritance interactions more database friendly.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-28 13:21:33 +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
0588dee34c queryset-refactor: Fixed a few really silly errors in the Q class and negation
handling in the tree class. Discovered whilst starting to fix exclude().


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7169 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-28 02:49:31 +00:00
Malcolm Tredinnick
c8afb75d53 queryset-refactor: Typo fix. Fixed #6670. Thanks, alex.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7166 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-27 02:47:32 +00:00
Malcolm Tredinnick
64315b9eec queryset-refactor: Removed some more dead code.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7165 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-27 02:47:14 +00:00
Malcolm Tredinnick
231e735c07 queryset-refactor: Moved the Query subclasses into their own file.
Trying to keep file lengths to something manageable.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-27 02:15:41 +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
fc4c0f7b39 queryset-refactor: Removed some unused code left over from an earlier attempt.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7162 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-27 00:43:40 +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
bdeba9ab94 queryset-refactor: Merged from trunk up to [7151].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7152 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-23 09:26:11 +00:00
Malcolm Tredinnick
cbd6da3540 queryset-refactor: Added valuelist() method to querysets. Refs #2482.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7149 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-23 03:36:38 +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
7355fa6b72 queryset-refactor: Implemented slicing to end of querysets.
Refs #2150, #5012.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7147 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-23 01:34:49 +00:00
Malcolm Tredinnick
e2f524ca09 queryset-refactor: Fixed the case of calling update() on a model manager.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7146 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-23 00:23:57 +00:00
Malcolm Tredinnick
e2b3c50cf0 queryset-refactor: Removed some tuple unpacking in a function signature.
This isn't going to be permitted in Python 3, so might as well not use it here.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7144 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-22 05:46:46 +00:00