summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
Commit message (Collapse)AuthorAgeFilesLines
* [soc2010/app-loading] merged trunkarchive/soc2010/app-loadingsoc2010/app-loadingArthur Koziel2010-09-131-2/+3
| | | | git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12851 -- Another attempt at fixing select_related() with inherited ↵Russell Keith-Magee2010-04-301-1/+11
| | | | | | models, this time with only(). Thanks to phxx for the test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13059 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #13227 -- Ensure that the query cache is flushed when a QuerySet is ↵Russell Keith-Magee2010-04-131-4/+5
| | | | | | deepcopied, avoiding problems when an evaluated queryset is used as a subquery. Thanks to claudep for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12970 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #13309 -- Ensure that delete() deletes everything it should delete(). ↵Russell Keith-Magee2010-04-091-1/+2
| | | | | | Thanks to craig.kimerer@gmail.com for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12941 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12328 -- Corrected the handling of subqueries with ordering and ↵Russell Keith-Magee2010-04-041-3/+6
| | | | | | | | slicing, especially when used in delete subqueries. Thanks to Walter Doekes for the report. This fixes a feature that isn't available under MySQL and Oracle (Refs #10099). git-svn-id: http://code.djangoproject.com/svn/django/trunk@12912 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12429 -- Ensure that raw queries call resolve_columns if the backend ↵Russell Keith-Magee2010-04-011-2/+9
| | | | | | defines it. This ensures (as much as possible) that the model values returned by a raw query match that in normal queries. Thanks to Ian Kelly for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12904 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12851 -- Corrected the interaction of defer() with select_related(). ↵Russell Keith-Magee2010-03-201-2/+2
| | | | | | Thanks to ruosteinen for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12817 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12937 -- Corrected the operation of select_related() when following ↵Russell Keith-Magee2010-03-201-6/+27
| | | | | | an reverse relation on an inherited model. Thanks to subsume for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12814 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12953 -- Ensure that deletion cascades through generic relations. ↵Russell Keith-Magee2010-03-151-2/+0
| | | | | | Also cleans up the special-casing of generic relations in the deleted object discovery process. Thanks to carljm for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12790 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12717 -- Corrected a problem with subqueries when using multidb ↵Russell Keith-Magee2010-03-101-2/+2
| | | | | | routing. Thanks to Jeff Balogh for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12755 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #13003 -- Ensured that ._state.db is set correctly for ↵Russell Keith-Magee2010-03-071-9/+15
| | | | | | select_related() queries. Thanks to Alex Gaynor for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12701 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12731. Fixed a bug with .raw() and inheritance. Thanks, Alex Gaynor.Joseph Kocherhans2010-02-231-1/+1
| | | | git-svn-id: http://code.djangoproject.com/svn/django/trunk@12544 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12819. Fixed a bug with caching values of nullable 1to1 fields. ↵Joseph Kocherhans2010-02-231-1/+1
| | | | | | Thanks, s.angel@twidi.com for the initial patch, and Alex Gaynor for the tests. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12543 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12608 -- No longer return inconsistent results when using `values` ↵Justin Bronn2010-02-231-1/+2
| | | | | | and `values_list` in conjunction with `annotate`. Thanks, Charlie Leifer. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12505 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12806 -- Added an implementation of `RawQuerySet.__getitem__`. ↵Justin Bronn2010-02-231-0/+3
| | | | | | Thanks, Bruno Renié. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12504 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #7270 -- Added the ability to follow reverse OneToOneFields in ↵Russell Keith-Magee2010-01-271-1/+73
| | | | | | select_related(). Thanks to George Vilches, Ben Davis, and Alex Gaynor for their work on various stages of this patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12307 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12540, #12541 -- Added database routers, allowing for configurable ↵Russell Keith-Magee2010-01-221-7/+18
| | | | | | database use behavior in a multi-db setup, and improved error checking for cross-database joins. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12272 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Changed a whole bunch of places to raise exception instances instead of ↵Adrian Holovaty2010-01-101-1/+1
| | | | | | old-style raising exception classes plus a comma. Good for the future Python 3 conversion git-svn-id: http://code.djangoproject.com/svn/django/trunk@12180 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12142 -- EmptyQuerySet.update() no longer updates all rows in the ↵Adrian Holovaty2010-01-101-0/+6
| | | | | | database git-svn-id: http://code.djangoproject.com/svn/django/trunk@12171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #7235 -- EmptyQuerySet no longer raises and exception when it's ↵Adrian Holovaty2010-01-091-0/+75
| | | | | | filter()ed (along with some other QuerySet methods). Thanks, taylormarshall git-svn-id: http://code.djangoproject.com/svn/django/trunk@12147 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Changes to get raw queries working on the oracle backend.Ian Kelly2009-12-221-1/+2
| | | | git-svn-id: http://code.djangoproject.com/svn/django/trunk@11968 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #1142 -- Added multiple database support.Russell Keith-Magee2009-12-221-49/+110
| | | | | | | | | | | | | | | | | This monster of a patch is the result of Alex Gaynor's 2009 Google Summer of Code project. Congratulations to Alex for a job well done. Big thanks also go to: * Justin Bronn for keeping GIS in line with the changes, * Karen Tracey and Jani Tiainen for their help testing Oracle support * Brett Hoerner, Jon Loyens, and Craig Kimmerer for their feedback. * Malcolm Treddinick for his guidance during the GSoC submission process. * Simon Willison for driving the original design process * Cal Henderson for complaining about ponies he wanted. ... and everyone else too numerous to mention that helped to bring this feature into fruition. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #11863: added a `Model.objects.raw()` method for executing raw SQL ↵Jacob Kaplan-Moss2009-12-201-2/+85
| | | | | | | | | | queries and yield models. See `docs/topics/db/raw.txt` for details. Thanks to seanoc for getting the ball rolling, and to Russ for wrapping things up. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11921 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12258 - QuerySet.get() should clear ordering.Luke Plant2009-12-191-0/+2
| | | | | | | | | | | We only clear ordering when doing so cannot change the result returned by the get() method i.e. when the query does not already define limits. Thanks to mattdennewitz@gmail.com for the report, and jdunck for the patch git-svn-id: http://code.djangoproject.com/svn/django/trunk@11916 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #12251 - QuerySet.in_bulk() should accept set/frozensetLuke Plant2009-12-191-1/+1
| | | | | | | | Thanks to emulbreh for patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11915 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #11753 - Q objects with callables no longer explode on Python 2.4. ↵Jacob Kaplan-Moss2009-12-171-1/+1
| | | | | | Thanks, Jeremy Dunck. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Optimised use of 'in' operator on QuerySet using an explicit __contains__ ↵Luke Plant2009-12-091-0/+30
| | | | | | | | | | | method. Without this change, use of 'in' on a QuerySet resulted in ._result_cache being fully populated, which sometimes is unnecessary work. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11803 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10109 -- Removed the use of raw SQL in many-to-many fields by ↵Russell Keith-Magee2009-11-031-2/+4
| | | | | | | | introducing an autogenerated through model. This is the first part of Alex Gaynor's GSoC project to add Multi-db support to Django. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11710 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #11402: added a `QuerySet.exists()` method. Thanks, Alex Gaynor.Jacob Kaplan-Moss2009-10-241-7/+5
| | | | git-svn-id: http://code.djangoproject.com/svn/django/trunk@11646 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #11082 -- Ensured that subqueries used in an exclude(X__in=) clause ↵Russell Keith-Magee2009-06-061-0/+13
| | | | | | aren't pre-evaluated. Thanks to Henry Andrews for the report, and clement for the fix. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10929 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10572 -- Corrected the operation of the defer() and only() clauses ↵Russell Keith-Magee2009-06-061-1/+19
| | | | | | when used on inherited models. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #9479 -- Corrected an edge case in bulk queryset deletion that could ↵Russell Keith-Magee2009-06-031-1/+2
| | | | | | cause an infinite loop when using MySQL InnoDB. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10913 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #9308 -- Corrected the updated of nullable foreign key fields when ↵Russell Keith-Magee2009-05-191-3/+3
| | | | | | deleting objects. Thanks to Bob Thomas for the fix, and markshep for the improvements on the test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10822 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10847 -- Modified handling of extra() to use a masking strategy, ↵Russell Keith-Magee2009-04-301-8/+9
| | | | | | | | rather than last-minute trimming. Thanks to Tai Lee for the report, and Alex Gaynor for his work on the patch. This enables querysets with an extra clause to be used in an __in filter; as a side effect, it also means that as_sql() now returns the correct result for any query with an extra clause. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Added a `QuerySet.ordered` property to check if a queryset is already ↵Jacob Kaplan-Moss2009-04-221-0/+17
| | | | | | ordered. Refs #10163. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10623 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed deferred fields and select_related() interaction.Malcolm Tredinnick2009-04-041-23/+26
| | | | | | | | | | Loading related models when some fields were deferred was resulting in incorrect offsets being used into the results row, causing the wrong data to be assigned to attributes. Refs #10710. This fixes the first of two bugs reported there. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10383 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10695 -- Fixed implementation of deferred attribute retrieval.Malcolm Tredinnick2009-04-041-18/+17
| | | | | | | | | | The original implementation had a few silly bugs in it that meant that data was not being used only on the instance of the class that it was appropriate for (one of the traps when using class-level things). No more! Thanks to Justin Bronn and Alex Gaynor for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10382 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Typo fix for an error path in r100090.Malcolm Tredinnick2009-03-191-1/+1
| | | | git-svn-id: http://code.djangoproject.com/svn/django/trunk@10091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #5420 -- Added support for delayed loading of model fields.Malcolm Tredinnick2009-03-191-106/+87
| | | | | | | | | | In extreme cases, some fields are expensive to load from the database (e.g. GIS fields requiring conversion, or large text fields). This commit adds defer() and only() methods to querysets that allow the caller to specify which fields should not be loaded unless they are accessed. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10090 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #3460 -- Added an ability to enable true autocommit for psycopg2 backend.Malcolm Tredinnick2009-03-111-47/+71
| | | | | | | | | Ensure to read the documentation before blindly enabling this: requires some code audits first, but might well be worth it for busy sites. Thanks to nicferrier, iamseb and Richard Davies for help with this patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10029 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* To avoid an unfortunately common user-error, rename QuerySet.as_sql().Malcolm Tredinnick2009-03-011-5/+2
| | | | | | | This was never a public API method, so this is backwards compatible, unless you're poking at the internals. Refs #10352. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9928 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10182 -- Corrected realiasing and the process of evaluating values() ↵Russell Keith-Magee2009-02-231-4/+12
| | | | | | | | for queries with aggregate clauses. This means that aggregate queries can now be used as subqueries (such as in an __in clause). Thanks to omat for the report. This involves a slight change to the interaction of annotate() and values() clauses that specify a list of columns. See the docs for details. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9888 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10132 -- Corrected the interaction of extra() queries with the ↵Russell Keith-Magee2009-02-161-1/+2
| | | | | | values() clause. Thanks to Glen Maynard for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9838 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10256 -- Corrected the interaction of extra(select=) with values() ↵Russell Keith-Magee2009-02-161-18/+34
| | | | | | and values_list() where an explicit list of columns is requested. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9837 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10199 -- Modified aggregate() calls to clone the base query so that ↵Russell Keith-Magee2009-02-081-2/+4
| | | | | | the base query can be reused. Thanks to Alex Gaynor for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9819 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10127 -- Corrected (no, really, this time!) the way the ↵Russell Keith-Magee2009-02-031-2/+4
| | | | | | select_related() cache is populated when annotations are also contained in the query. Thanks to Sylvain Pasche <sylvain.pasche@gmail.com> for the report and test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9808 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #10127 -- Corrected handling of select_related() in annotate() calls. ↵Russell Keith-Magee2009-02-021-2/+2
| | | | | | Thanks to Sylvain Pasche <sylvain.pasche@gmail.com> for the report and test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9805 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #9997 -- Fixed use of ValuesQuerySets as rvalues in filters.Malcolm Tredinnick2009-01-161-0/+14
| | | | | | | Previous behaviour was pretty stupid. Let's never speak of it again. New behaviour both works and is documented. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9759 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #3566 -- Added support for aggregation to the ORM. See the ↵Russell Keith-Magee2009-01-151-7/+82
| | | | | | | | | | | | | | documentation for details on usage. Many thanks to: * Nicolas Lara, who worked on this feature during the 2008 Google Summer of Code. * Alex Gaynor for his help debugging and fixing a number of issues. * Justin Bronn for his help integrating with contrib.gis. * Karen Tracey for her help with cross-platform testing. * Ian Kelly for his help testing and fixing Oracle support. * Malcolm Tredinnick for his invaluable review notes. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9742 bcc190cf-cafb-0310-a4f2-bffc1f526a37
* Fixed #9985 -- qs.values_list(...).values(...) was constructing incorrect SQL.Malcolm Tredinnick2009-01-081-1/+5
| | | | git-svn-id: http://code.djangoproject.com/svn/django/trunk@9717 bcc190cf-cafb-0310-a4f2-bffc1f526a37