summaryrefslogtreecommitdiff
path: root/django/db/models/sql
AgeCommit message (Collapse)Author
2008-10-24Fixed #9307 -- Added the ability to pickle the Query class used by the OracleMalcolm Tredinnick
backend. This allows Querysets to be cached for Oracle and should provide a model for adding pickling support to other (external) database backends that need a custom Query class. Thanks to Justin Bronn for some assistance with this patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9272 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-24Fixed #9406 -- Ensure that each database column is only represented once in theMalcolm Tredinnick
"ORDER BY" clause of an SQL statement. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9251 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-08A queryset that has had ordering removed (order_by()) can have ordering addedMalcolm Tredinnick
again later (order_by('foo')). Or, at least, it can now. Thanks to Ilya Novoselov for diagnosing the problem here. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-08Applying a limit to a queryset that already had an upper limit of 0 wasn'tMalcolm Tredinnick
working properly. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9201 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-05Fixed #9068 -- Fixed a couple of typos in InsertQuery.clone(). Thanks, rush.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9150 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-28Fixed Queryset.dates() in the presence of extra-select columns.Malcolm Tredinnick
Any extra(select=...) columns can be ignored in the SQL for dates, since we are only interested in extracting distinct date values. We were previously including them by accident and it was generating incorrect SQL. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-22Fixed a missing variable initialisation deep in the Query bowels.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9081 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-11Fixed a typo so that cloning UpdateQuery objects won't fail mysteriously.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9008 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-11A bug from queryset-refactor days: although the Query class has "group_by" andMalcolm Tredinnick
"having" attributes, only the former was included in the resulting SQL, meaning subclasses had to completely duplicate Query.as_sql() if they were using any kind of grouping filtering on the results. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9007 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-03Fixed #8819 -- Don't include two copies of extra-select columns in the query.Malcolm Tredinnick
This was triggered by r8794, but was, in fact, fairly fragile before then. The current fix is the correct way we should be doing this. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8898 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-02Fixed #8790 -- Multi-branch join trees that shared tables of the same name wereMalcolm Tredinnick
sometimes also sharing aliases, instead of creating their own. This was generating incorrect SQL. No representative test for this fix yet because I haven't had time to write one that fits in nicely with the test suite. But it works for the monstrous example in #8790 and a bunch of other complex examples I've created locally. Will write a test later. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8853 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-02Fixed #8439 -- Complex combinations of Q-objects (using both conjunctions andMalcolm Tredinnick
disjunctions) were producing incorrect SQL when nullable relations were involved. This fixes that. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8832 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-02A typo fix that fortunately wasn't creating invalid SQL, just slightly lessMalcolm Tredinnick
efficient than possible SQL in some odd cases (found via code inspection, not any particular failing example). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8831 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-02Get the join promotion code (a bit more) correct when constructing joins for ↵Malcolm Tredinnick
ordering. Yes, this really is a commit that fixes an oversight in a commit that fixed an oversight. One day I'll get it right. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8829 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-01Replaced exact lookups of the empty string with isnull lookups in Oracle. ↵Ian Kelly
Fixes the testPreventDuplicateComments case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8827 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-01Fixed extra_select with DateQuery in OracleIan Kelly
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8804 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-01Fixed #7302: Corrected quoting of columns in extra_group_by. Thanks to Ivan ↵Russell Keith-Magee
Sagalaev for the patch and initial test. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8794 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-09-01Fixed #7512 -- Fixed an oversight when I first fixed ordering on nullableMalcolm Tredinnick
foreign keys (r7761). Thanks to George Vilches for the test case here. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8783 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-28Improvements to [8608] to fix an infinite loop (for exclude(generic_relation)).Malcolm Tredinnick
Also comes with approximately 67% less stupidity in the table joins for filtering on generic relations. Fixed #5937, hopefully for good, this time. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8644 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-27Fixed #5937 -- When filtering on generic relations, restrict the target ↵Malcolm Tredinnick
objects to those with the right content type. This isn't a complete solution to this class of problem, but it will do for 1.0, which only has generic relations as a multicolumn type. A more general multicolumn solution will be available after that release. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8608 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-25Fixed #8106 -- Untangled some problems with complex select_related() queriesMalcolm Tredinnick
and models that have multiple paths to them from other models. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8559 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-22Fixed #8046 -- The first filter() call on a related manager for many-to-manyMalcolm Tredinnick
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-20Made it possible to pickle DateQuerySets.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8455 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-17Fixed #8039 -- Make sure that extra(tables=...) tables are always included inMalcolm Tredinnick
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-17Changed the (internal) way extra(select=.., select_params=...) handling is doneMalcolm Tredinnick
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-09Added the ability to force an SQL insert (or force an update) via a model'sMalcolm Tredinnick
save() method. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8267 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-06Major refactoring of django.dispatch with an eye towards speed. The net ↵Jacob Kaplan-Moss
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-07-27Fixed #7886 -- Reordered some code in Query.results_iter() to ensure that allMalcolm Tredinnick
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-27Fixed #7872 -- Fixed a missed case of promoting table joins when usingMalcolm Tredinnick
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-23Allow for matches against unsaved objects in querysets (which will thereforeMalcolm Tredinnick
match nothing). This allows for some more straightforward code in the admin interface. Fixed #7488 (all the debugging there was done by Brian Rosner, who narrowed it down to the item in this patch). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8061 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22Fixed #7813 -- Allow pickling of Query classes that use select_related().Malcolm Tredinnick
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-22Fixed #7791 -- Fixed a really silly error I introduced in [7926]. :-(Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8052 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22Fixed #7848 -- Removed a bunch of code that wasn't contributing to society. ↵Adrian Holovaty
Thanks, julien git-svn-id: http://code.djangoproject.com/svn/django/trunk@8047 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22Fixed #7847 -- Removed a whole bunch of unused imports from throughout the ↵Adrian Holovaty
codebase. Thanks, julien git-svn-id: http://code.djangoproject.com/svn/django/trunk@8046 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-15Fixed #7411 -- worked around some possible transaction conflicts in SQLite.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-12Fixed a bozo bug from [7885]. Fixed #7698.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-11Removed a FIXME that isn't really a problem any longer.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7886 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-11Fixed #7698 -- Handle '0' correctly when used as the upper bound of a slice.Malcolm Tredinnick
Based on a patch from enoksrd. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7885 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-04Redo the changes in [7773] in a better way.Malcolm Tredinnick
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-01Modified [7760] to not include a "col is not NULL" fragment for non-nullable ↵Malcolm Tredinnick
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-06-30Fixed #7314 -- Changed the way extra() bits are handled when QuerySets are ↵Malcolm Tredinnick
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-29A way better fix for the count() issue in [7787].Malcolm Tredinnick
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-29Fixed #7323 -- Fixed a count() edge-case.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7787 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29Fixed #7371 -- Fixed an edge case when ordering on related models.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7786 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29Factored out a semi-complex if-test that was used in two places.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7782 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29Fixed #7246 -- Pull in the all the necessary data when using ↵Malcolm Tredinnick
select_related() with multi-table inheritance. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7781 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-29Fixed handling of multiple fields in a model pointing to the same related model.Malcolm Tredinnick
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-27Removed a dead line that was left in [7773] by accident.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-06-27Reorganised the internals of the Where node a bit to fix some copying problems.Malcolm Tredinnick
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-26Fixed #7105 -- Fixed dates() queries in light of model inheritance.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7763 bcc190cf-cafb-0310-a4f2-bffc1f526a37