Commit Graph

33 Commits

Author SHA1 Message Date
Malcolm Tredinnick d4d7bc175d Fixed #8046 -- The first filter() call on a related manager for many-to-many
fields no longer creates duplicate copies of the join table(s). Basically, this
means filters on the join table (for ManyToManyField(through=...)) and complex
filters in the normal (non-through) case don't produce incorrect or duplicate
results.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8472 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-22 22:00:28 +00:00
Malcolm Tredinnick 556fbc78a6 Fixed #8039 -- Make sure that extra(tables=...) tables are always included in
the resulting SQL. Previously, an optimisation was removing them in some corner
cases.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8429 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-17 22:38:36 +00:00
Malcolm Tredinnick 2c4b13cbe7 Changed the (internal) way extra(select=.., select_params=...) handling is done
so that parameters stay with their select items. This means that merging and
trimming of those items is handled correctly.

Refs #7957, #7961. Fixed #8191.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8426 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-17 20:07:59 +00:00
Jacob Kaplan-Moss 34a3bd5225 Major refactoring of django.dispatch with an eye towards speed. The net result is that signals are up to 90% faster.
Though some attempts and backwards-compatibility were made, speed trumped compatibility. Thus, as usual, check BackwardsIncompatibleChanges for the complete list of backwards-incompatible changes.

Thanks to Jeremy Dunck and Keith Busell for the bulk of the work; some ideas from Brian Herring's previous work (refs #4561) were incorporated.

Documentation is, sigh, still forthcoming.

Fixes #6814 and #3951 (with the new dispatch_uid argument to connect).


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8223 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-06 15:32:46 +00:00
Malcolm Tredinnick 2c6d1e8ebc Fixed #7886 -- Reordered some code in Query.results_iter() to ensure that all
the prequisites are correctly initialised prior to using them. Only affects
Oracle and other db backends requiring resolve_columns() (e.g. MS SQL?)


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8112 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-27 18:38:56 +00:00
Malcolm Tredinnick 4fee39c63c Fixed #7872 -- Fixed a missed case of promoting table joins when using
disjunctive filters. Thanks to Michael Radziej for the failing test case.
problem.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8107 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-27 18:16:17 +00:00
Malcolm Tredinnick 8745beccb1 Fixed #7813 -- Allow pickling of Query classes that use select_related().
Based on a patch from Justin Bronn.

The test in this patch most likely breaks on Oracle. That's another issue.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8053 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22 08:23:20 +00:00
Malcolm Tredinnick 83e97ecf88 Fixed #7791 -- Fixed a really silly error I introduced in [7926]. :-(
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8052 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22 07:37:09 +00:00
Adrian Holovaty 0894ddb2bb Fixed #7848 -- Removed a bunch of code that wasn't contributing to society. Thanks, julien
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8047 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22 03:26:25 +00:00
Adrian Holovaty 29f0e8182f Fixed #7847 -- Removed a whole bunch of unused imports from throughout the codebase. Thanks, julien
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8046 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22 03:24:09 +00:00
Malcolm Tredinnick 3b37c8151a Fixed #7411 -- worked around some possible transaction conflicts in SQLite.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-15 18:47:32 +00:00
Malcolm Tredinnick 52d985fac3 Fixed a bozo bug from [7885]. Fixed #7698.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-12 11:01:57 +00:00
Malcolm Tredinnick c742afb3b2 Removed a FIXME that isn't really a problem any longer.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7886 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-11 12:44:04 +00:00
Malcolm Tredinnick 2b193f6100 Fixed #7698 -- Handle '0' correctly when used as the upper bound of a slice.
Based on a patch from enoksrd.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7885 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-11 12:43:27 +00:00
Malcolm Tredinnick 6dd2b5468f Redo the changes in [7773] in a better way.
This removes some of the leaky abstraction problems (lifting WhereNode
internals into the Query class) from that commit and makes it possible for
extensions to WhereNode to have access to the field instances. It's also
backwards-compatible with pre-[7773] code, which is also better.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7835 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-04 06:42:58 +00:00
Malcolm Tredinnick 4fd359253d Modified [7760] to not include a "col is not NULL" fragment for non-nullable fields.
This avoids any use of "pk is not NULL" fragment, which behave inconsistently
in MySQL. Thanks to Russell Keith-Magee for diagnosing the problem and
suggesting the easy fix.

Refs #7076.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7812 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-01 10:12:50 +00:00
Malcolm Tredinnick 5da47e43c7 Fixed #7314 -- Changed the way extra() bits are handled when QuerySets are merged.
Also added a section to the documentation to indicate why it's probably not a
good idea to rely on this feature for complex stuff. Garbage in, garbage out
applies even to Django code.

Thanks to erik for the test case for this one.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7791 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-30 06:24:21 +00:00
Malcolm Tredinnick f62e5a1fba A way better fix for the count() issue in [7787].
The first attempt was brain-damaged. Let's never speak of it again.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7788 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29 23:47:31 +00:00
Malcolm Tredinnick 18d89cc1f7 Fixed #7323 -- Fixed a count() edge-case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7787 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29 11:50:04 +00:00
Malcolm Tredinnick 050d0a1b75 Fixed #7371 -- Fixed an edge case when ordering on related models.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7786 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29 11:15:48 +00:00
Malcolm Tredinnick 5326cd293e Factored out a semi-complex if-test that was used in two places.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7782 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29 09:40:17 +00:00
Malcolm Tredinnick a8fa3fd81f Fixed #7246 -- Pull in the all the necessary data when using select_related() with multi-table inheritance.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7781 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29 09:39:32 +00:00
Malcolm Tredinnick bb2182453b Fixed handling of multiple fields in a model pointing to the same related model.
Thanks to ElliotM, mk and oyvind for some excellent test cases for this. Fixed #7110, #7125.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7778 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29 02:36:18 +00:00
Malcolm Tredinnick ade4a1246c Reorganised the internals of the Where node a bit to fix some copying problems.
We no longer store any reference to Django field instances or models in the
Where node. This should improve cloning speed, fix some pickling difficulties,
reduce memory usage and remove some infinite loop possibilities in odd cases.
Slightly backwards incompatible if you're writing custom filters. See the
BackwardsIncompatibleChanges wiki page for details.

Fixed #7128, #7204, #7506.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7773 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-27 03:27:20 +00:00
Malcolm Tredinnick ba015e0a79 Fixed #7181 -- when ordering by a potentially NULL field, use a left-outer join
so that the ordering doesn't accidentally restrict the result set.

(Ironically, one existing test actually showed this problem, but I was too
dumb to notice the result was incorrect.)


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7761 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 06:50:22 +00:00
Malcolm Tredinnick e41df5adcc Fixed #7076 -- Include NULL values when excluding non-NULL items.
Based on a patch from emulbreh.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7760 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 05:34:26 +00:00
Malcolm Tredinnick 588eeb356c Fixed a problem when constructing complex select_related() calls.
Avoids joining with the wrong tables when connecting select_related() tables to
the main query. This also leads to slightly more efficient (meaning less tables
are joined) SQL queries in some other cases, too. Some unnecessary tables are
now trimmed that were not previously.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7741 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 01:02:11 +00:00
Malcolm Tredinnick 1834428648 Fixed a problem with values() and values_list() queries and nullable joins.
Previously, if we were querying across a nullable join and then a non-nullable
one, the second join would not be a LEFT OUTER join, which would exclude
certain valid results from the result set.

This is the same problem as [7597] but for values() field specifications, so
this covers the second case where Django adds extra stuff to the select-clause.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7740 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-26 01:01:21 +00:00
Jacob Kaplan-Moss 31d9dc07aa Fixed #7369: fixed a corner-case involving select_related() following non-null FKs after null ones. Thanks, George Vilches
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7597 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-08 18:13:46 +00:00
Adrian Holovaty 14d6ee2dc9 Changed Query.get_columns() to quote the 'AS' column names in an extra_select situation, to match pre-queryset-refactor behavior. Added unit tests that verify this and provide an example
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7502 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-28 21:15:05 +00:00
Malcolm Tredinnick a97f690e5d Added the ability to pickle and unpickle QuerySets and Query classes.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7499 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-28 14:14:41 +00:00
Malcolm Tredinnick e07a457c00 Fixed #7096 -- The simplifications in [7461] weren't complete. They broke
multi-component exclude() calls. Fixed that.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7493 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-28 04:29:06 +00:00
Malcolm Tredinnick 9c52d56f6f Merged the queryset-refactor branch into trunk.
This is a big internal change, but mostly backwards compatible with existing
code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7477 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-04-27 02:50:16 +00:00