summaryrefslogtreecommitdiff
path: root/django/db/models/sql
AgeCommit message (Collapse)Author
2009-05-29[1.0.X] Fixed #11216 and #11218 -- Corrected a few typos, thanks buriy.Gary Wilson Jr
Backport of [10861] from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10862 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-24[1.0.X] Fixed #9926 -- Fixes for some select_related() situations.Malcolm Tredinnick
Using select_related(...) across a nullable relation to a multi-table model inheritance situation no longer excludes results. Thanks to AdamG for a test demonstrating part of the problem. Backport of r10136 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10138 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-09[1.0.X] Pass values through get_db_prep_save() in a QuerySet.update() call.Malcolm Tredinnick
This removes a long-standing FIXME in the update() handling and allows for greater flexibility in the values passed in. In particular, it brings updates into line with saves for django.contrib.gis fields, so fixed #10411. Thanks to Justin Bronn and Russell Keith-Magee for help with this patch. Backport of r10003 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10004 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-08[1.0.X] Fixed #10432 -- Handle all kinds of iterators in queryset filters.Malcolm Tredinnick
Only consumes the iterators once and works with Python 2.3. Backport of r9986 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9987 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-06[1.0.X] Improved table join handling for comparisons against NULL.Malcolm Tredinnick
This fixes a broad class of bugs involving filters that look for missing related models and fields. Most of them don't seem to have been reported (the added tests cover the root cause). The exception is that this has also fixed #9968. Backport of r9979 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9980 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-04[1.0.X] Fixed #10251 -- Fixed model inheritance when there's also an ↵Malcolm Tredinnick
explicit pk field. Backport of r9970 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9972 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-04[1.0.X] Changed the row count value returned from update queries in some cases.Malcolm Tredinnick
If an update only affected an ancestor model (not the child), we were returning 0 for the number of rows updated. This could have been misleading if the value is used to detect an update occuring. So we now return the rowcount from the first non-trivial query that is executed (if any). Still a slight compromise, but better than what we had. Backport of r9966 from trunk (turns out this *is* a bugfix, since the returned rowcount is used in Model.save(force_update=True)). git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9969 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-04[1.0.X] Fixed #10362 -- An update() that only affects a parent model no ↵Malcolm Tredinnick
longer crashes. This includes a fairly large refactor of the update() query path (and the initial portions of constructing the SQL for any query). The previous code appears to have been only working more or less by accident and was very fragile. Backport of r9967 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9968 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-01[1.0.X] Fixed insert/update handling when no database interaction is required.Malcolm Tredinnick
Fixed #10205 as part of this. Backport of r9926 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9927 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-01[1.0.X] Fixed #10202 -- Fixed another couple of slicing edge-cases with ↵Malcolm Tredinnick
querysets. Patch from Alex Gaynor and Ramiro Morales. Backport of r9924 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9925 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-02-28[1.0.X] Fixed #10028 -- Fixed a problem when ordering by related models.Malcolm Tredinnick
Some results were inadvertently being excluded if we were ordering across a nullable relation which itself ordering by a non-nullable relation. Backport of r9916 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9917 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-08[1.0.X] Fixed #9985 -- qs.values_list(...).values(...) was constructing ↵Malcolm Tredinnick
incorrect SQL. Backport of r9717 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9718 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-12-08[1.0.X] This fixes a group of problems in the SQL created by QuerySet.exclude()Malcolm Tredinnick
when used in a few situations where NULL results can appear. Fixed #8921 (the only ticket I know of that noticed any of these). Backport of r9590 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9591 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-12-07[1.0.X] Fixed #9188 -- Fixed a case where we were generating syntactically ↵Malcolm Tredinnick
invalid SQL in some exclude() queries. Backport of r9588 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9589 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-24[1.0.X] Fixed #9307 -- Added the ability to pickle the Query class used by theMalcolm Tredinnick
Oracle 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. Backport of r9272 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9273 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-24[1.0.X] Fixed #9406 -- Ensure that each database column is only representedMalcolm Tredinnick
once in the "ORDER BY" clause of an SQL statement. Backport of r9251 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9252 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-08[1.0.X] A queryset that has had ordering removed (order_by()) can have orderingMalcolm Tredinnick
added again later (order_by('foo')). Or, at least, it can now. Thanks to Ilya Novoselov for diagnosing the problem here. Backport of r9206 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9207 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-08[1.0.X] Applying a limit to a queryset that already had an upper limit of 0Malcolm Tredinnick
wasn't working properly. Backport of r9201 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9204 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-10-05[1.0.X] Fixed #9068 -- Fixed a couple of typos in InsertQuery.clone(). ↵Malcolm Tredinnick
Thanks, rush. Backport of r9150 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9151 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