summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
AgeCommit message (Collapse)Author
2010-08-09[soc2010/query-refactor] Merged up to trunk r13556, resolved merge conflictsarchive/soc2010/query-refactorAlex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13565 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-07-13[soc2010/query-refactor] Implemented F() expressions for MongoDB.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13430 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-06-21[soc2010/query-refactor] Implemented values (and values_list).Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13372 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-06-09[soc2010/query-refactor] Fixed update on MongoDB.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13342 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-06-07[soc2010/query-refactor] Moved has_results (implementation of exists()) onto ↵Alex Gaynor
the compiler, where it belongs. git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13334 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-06-07[soc2010/query-refactor] Refactor, and implement a few more methods to get ↵Alex Gaynor
models saving under the mongodb backend. git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13332 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-04-30Fixed #12851 -- Another attempt at fixing select_related() with inherited ↵Russell Keith-Magee
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
2010-04-13Fixed #13227 -- Ensure that the query cache is flushed when a QuerySet is ↵Russell Keith-Magee
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
2010-04-09Fixed #13309 -- Ensure that delete() deletes everything it should delete(). ↵Russell Keith-Magee
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
2010-04-04Fixed #12328 -- Corrected the handling of subqueries with ordering and ↵Russell Keith-Magee
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
2010-04-01Fixed #12429 -- Ensure that raw queries call resolve_columns if the backend ↵Russell Keith-Magee
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
2010-03-20Fixed #12851 -- Corrected the interaction of defer() with select_related(). ↵Russell Keith-Magee
Thanks to ruosteinen for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12817 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-20Fixed #12937 -- Corrected the operation of select_related() when following ↵Russell Keith-Magee
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
2010-03-15Fixed #12953 -- Ensure that deletion cascades through generic relations. ↵Russell Keith-Magee
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
2010-03-10Fixed #12717 -- Corrected a problem with subqueries when using multidb ↵Russell Keith-Magee
routing. Thanks to Jeff Balogh for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12755 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-07Fixed #13003 -- Ensured that ._state.db is set correctly for ↵Russell Keith-Magee
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
2010-02-23Fixed #12731. Fixed a bug with .raw() and inheritance. Thanks, Alex Gaynor.Joseph Kocherhans
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12544 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-02-23Fixed #12819. Fixed a bug with caching values of nullable 1to1 fields. ↵Joseph Kocherhans
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
2010-02-23Fixed #12608 -- No longer return inconsistent results when using `values` ↵Justin Bronn
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
2010-02-23Fixed #12806 -- Added an implementation of `RawQuerySet.__getitem__`. ↵Justin Bronn
Thanks, Bruno Renié. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12504 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-27Fixed #7270 -- Added the ability to follow reverse OneToOneFields in ↵Russell Keith-Magee
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
2010-01-22Fixed #12540, #12541 -- Added database routers, allowing for configurable ↵Russell Keith-Magee
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
2010-01-10Changed a whole bunch of places to raise exception instances instead of ↵Adrian Holovaty
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
2010-01-10Fixed #12142 -- EmptyQuerySet.update() no longer updates all rows in the ↵Adrian Holovaty
database git-svn-id: http://code.djangoproject.com/svn/django/trunk@12171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-09Fixed #7235 -- EmptyQuerySet no longer raises and exception when it's ↵Adrian Holovaty
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
2009-12-22Changes to get raw queries working on the oracle backend.Ian Kelly
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11968 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-22Fixed #1142 -- Added multiple database support.Russell Keith-Magee
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
2009-12-20Fixed #11863: added a `Model.objects.raw()` method for executing raw SQL ↵Jacob Kaplan-Moss
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
2009-12-19Fixed #12258 - QuerySet.get() should clear ordering.Luke Plant
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
2009-12-19Fixed #12251 - QuerySet.in_bulk() should accept set/frozensetLuke Plant
Thanks to emulbreh for patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11915 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-17Fixed #11753 - Q objects with callables no longer explode on Python 2.4. ↵Jacob Kaplan-Moss
Thanks, Jeremy Dunck. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-09Optimised use of 'in' operator on QuerySet using an explicit __contains__ ↵Luke Plant
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
2009-11-03Fixed #10109 -- Removed the use of raw SQL in many-to-many fields by ↵Russell Keith-Magee
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
2009-10-24Fixed #11402: added a `QuerySet.exists()` method. Thanks, Alex Gaynor.Jacob Kaplan-Moss
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11646 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-06-06Fixed #11082 -- Ensured that subqueries used in an exclude(X__in=) clause ↵Russell Keith-Magee
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
2009-06-06Fixed #10572 -- Corrected the operation of the defer() and only() clauses ↵Russell Keith-Magee
when used on inherited models. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-06-03Fixed #9479 -- Corrected an edge case in bulk queryset deletion that could ↵Russell Keith-Magee
cause an infinite loop when using MySQL InnoDB. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10913 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-05-19Fixed #9308 -- Corrected the updated of nullable foreign key fields when ↵Russell Keith-Magee
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
2009-04-30Fixed #10847 -- Modified handling of extra() to use a masking strategy, ↵Russell Keith-Magee
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
2009-04-22Added a `QuerySet.ordered` property to check if a queryset is already ↵Jacob Kaplan-Moss
ordered. Refs #10163. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10623 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-04Fixed deferred fields and select_related() interaction.Malcolm Tredinnick
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
2009-04-04Fixed #10695 -- Fixed implementation of deferred attribute retrieval.Malcolm Tredinnick
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
2009-03-19Typo fix for an error path in r100090.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-19Fixed #5420 -- Added support for delayed loading of model fields.Malcolm Tredinnick
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
2009-03-11Fixed #3460 -- Added an ability to enable true autocommit for psycopg2 backend.Malcolm Tredinnick
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
2009-03-01To avoid an unfortunately common user-error, rename QuerySet.as_sql().Malcolm Tredinnick
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
2009-02-23Fixed #10182 -- Corrected realiasing and the process of evaluating values() ↵Russell Keith-Magee
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
2009-02-16Fixed #10132 -- Corrected the interaction of extra() queries with the ↵Russell Keith-Magee
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
2009-02-16Fixed #10256 -- Corrected the interaction of extra(select=) with values() ↵Russell Keith-Magee
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
2009-02-08Fixed #10199 -- Modified aggregate() calls to clone the base query so that ↵Russell Keith-Magee
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