summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
AgeCommit message (Collapse)Author
2014-08-30[1.7.x] Fixed #23370 -- defer() + select_related() crashed with inherited ↵Akis Kesoglou
models. Backport of 6613ea6e3f from master
2014-08-07[1.7.x] Fixed flake8 warning.Tim Graham
Backport of f9f9f3ad60 from master
2014-08-05[1.7.x] Fixed #23061: Avoided setting a limit on a query for get with ↵Shai Berger
select_for_update on Oracle Thanks Michael Miller for reporting the issue. Backport of 746f2a4bed from master
2014-05-29[1.7.x] Fixed several typos in DjangoAlex Gaynor
Backport of 1dcc603eff from master
2014-05-21[1.7.x] Fixed the ordering of prefetch lookups so that latter lookups can ↵Loic Bistuer
refer to former lookups. Thanks Anssi Kääriäinen and Tim Graham for the reviews. Refs #17001 and #22650. Backport of 870b0a1f86 from master
2014-05-21[1.7.x] Fixed #22650 -- Fixed regression on prefetch_related.Loic Bistuer
Regression from f51c1f59 when using select_related then prefetch_related on the reverse side of an O2O: Author.objects.select_related('bio').prefetch_related('bio__books') Thanks Aymeric Augustin for the report and tests. Refs #17001. Backport of bdf3473e64 from master
2014-05-10[1.7.x] Fixed #22508 -- Avoided overwriting select_related.Aymeric Augustin
Previously, known related objects overwrote related objects loaded though select_related. This could cancel the effect of select_related when it was used over more than one level. Thanks boxm for the bug report and timo for bisecting the regression. Backport of f574220f from master
2014-04-26[1.7.x] Fix many many typos in comments throughout the codebaseAlex Gaynor
Backport of 2bcb8bfc8d from master
2014-03-20Fixed #22163 -- Stopped ignoring unhandled kwargs in select_for_update.Aymeric Augustin
2014-03-03Allowed custom querysets when prefetching single valued relationsLoic Bistuer
The original patch for custom prefetches didn't allow usage of custom queryset for single valued relations (along ForeignKey or OneToOneKey). Allowing these enables calling performance oriented queryset methods like select_related or defer/only. Thanks @akaariai and @timgraham for the reviews. Refs #17001.
2014-03-03Fixed many typos in comments and docstrings.Rodolfo Carvalho
Thanks Piotr Kasprzyk for help with the patch.
2014-02-17Fixed #22023 -- Raised an error for values() followed by defer() or only().Artur Frysiak
Previously, doing so resulted in invalid data or crash. Thanks jtiai for the report and Karol Jochelson, Jakub Nowak, Loic Bistuer, and Baptiste Mispelon for reviews.
2014-02-15Fixed #19299 -- Fixed Nullification of Foreign Keys To CharFieldsAlbert Wang
Thanks tunixman for the report and Baptiste Mispelon and Shai Berger for reviews.
2014-02-02Ensure cursors are closed when no longer needed.Michael Manfre
This commit touchs various parts of the code base and test framework. Any found usage of opening a cursor for the sake of initializing a connection has been replaced with 'ensure_connection()'.
2014-02-02Made SQLCompiler.execute_sql(result_type) more explicit.Michael Manfre
Updated SQLUpdateCompiler.execute_sql to match the behavior described in the docstring; the 'first non-empty query' will now include all queries, not just the main and first related update. Added CURSOR and NO_RESULTS result_type constants to make the usages more self documenting and allow execute_sql to explicitly close the cursor when it is no longer needed.
2013-12-14Fixed E127 pep8 warnings.Loic Bistuer
2013-12-06Fixed #21566 -- Fixed AttributeError when using bulk_create with ForeignObject.Roger Hu
2013-11-28Fixed E125 pep8 warningsChristopher Medrela
2013-11-27Added a bulk option to RelatedManager remove() and clear() methodsLoic Bistuer
Refs #21169
2013-11-27Used simpler queries for m2m clearing when possible.Anssi Kääriäinen
Refs #21169
2013-11-15Fixed the use of the -ise suffix, where -ize is preferedAlex Gaynor
2013-11-07Fixed #17001 -- Custom querysets for prefetch_related.Loic Bistuer
This patch introduces the Prefetch object which allows customizing prefetch operations. This enables things like filtering prefetched relations, calling select_related from a prefetched relation, or prefetching the same relation multiple times with different querysets. When a Prefetch instance specifies a to_attr argument, the result is stored in a list rather than a QuerySet. This has the fortunate consequence of being significantly faster. The preformance improvement is due to the fact that we save the costly creation of a QuerySet instance. Thanks @akaariai for the original patch and @bmispelon and @timgraham for the reviews.
2013-11-03Fixed all E226 violationsAlex Gaynor
2013-11-02Fixed all E261 warningscoagulant
2013-11-02Fixed #21302 -- Fixed unused imports and import *.Tim Graham
2013-10-21Fixed #21288 -- Fixed E126 pep8 warningsAlasdair Nicol
2013-10-01OrderedDict creation avoidance for .values() queriesAnssi Kääriäinen
Avoid accessing query.extra and query.aggregates directly for .values() queries. Refs #20950.
2013-09-30Fixed #21134 -- Prevented queries in broken transactions.Aymeric Augustin
Squashed commit of the following: commit 63ddb271a44df389b2c302e421fc17b7f0529755 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Sep 29 22:51:00 2013 +0200 Clarified interactions between atomic and exceptions. commit 2899ec299228217c876ba3aa4024e523a41c8504 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Sep 22 22:45:32 2013 +0200 Fixed TransactionManagementError in tests. Previous commit introduced an additional check to prevent running queries in transactions that will be rolled back, which triggered a few failures in the tests. In practice using transaction.atomic instead of the low-level savepoint APIs was enough to fix the problems. commit 4a639b059ea80aeb78f7f160a7d4b9f609b9c238 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Tue Sep 24 22:24:17 2013 +0200 Allowed nesting constraint_checks_disabled inside atomic. Since MySQL handles transactions loosely, this isn't a problem. commit 2a4ab1cb6e83391ff7e25d08479e230ca564bfef Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sat Sep 21 18:43:12 2013 +0200 Prevented running queries in transactions that will be rolled back. This avoids a counter-intuitive behavior in an edge case on databases with non-atomic transaction semantics. It prevents using savepoint_rollback() inside an atomic block without calling set_rollback(False) first, which is backwards-incompatible in tests. Refs #21134. commit 8e3db393853c7ac64a445b66e57f3620a3fde7b0 Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Sep 22 22:14:17 2013 +0200 Replaced manual savepoints by atomic blocks. This ensures the rollback flag is handled consistently in internal APIs.
2013-09-30Fixed #13724: Corrected routing of write queries involving managers.Russell Keith-Magee
Previously, if a database request spanned a related object manager, the first manager encountered would cause a request to the router, and this would bind all subsequent queries to the same database returned by the router. Unfortunately, the first router query would be performed using a read request to the router, resulting in bad routing information being used if the subsequent query was actually a write. This change defers the call to the router until the final query is acutally made. It includes a small *BACKWARDS INCOMPATIBILITY* on an edge case - see the release notes for details. Thanks to Paul Collins (@paulcollinsiii) for the excellent debugging work and patch.
2013-09-08Removed an unused local varAlex Gaynor
2013-08-30Fixed #20989 -- Removed useless explicit list comprehensions.Simon Charette
2013-08-29Fixed #20989 -- Removed explicit list comprehension inside dict() and tuple()Tim Graham
Thanks jeroen.pulles at redslider.net for the suggestion and helper script.
2013-08-21Fixed a regression with get_or_create and virtual fields.Tim Graham
refs #20429 Thanks Simon Charette for the report and review.
2013-08-19Fixed #12886 -- aggregation over sliced querysetAnssi Kääriäinen
2013-08-06Fixed #19918 -- Modified select_for_update to run on the write database.Alex Cucu
2013-07-31Fixed #20826 -- Moved Manager.raw() and Manager._insert() to the QuerySet class.Loic Bistuer
2013-07-31Fixed #15624 -- Made sure aggregations are present in SELECTFlorian Hahn
2013-07-26Fixed #20625 -- Chainable Manager/QuerySet methods.Loic Bistuer
Additionally this patch solves the orthogonal problem that specialized `QuerySet` like `ValuesQuerySet` didn't inherit from the current `QuerySet` type. This wasn't an issue until now because we didn't officially support custom `QuerySet` but it became necessary with the introduction of this new feature. Thanks aaugustin, akaariai, carljm, charettes, mjtamlyn, shaib and timgraham for the reviews.
2013-07-23Fixed test failures introduced in e716518ad29898fb25c820023aaf2fdd1c9eb4afTim Graham
refs #20761
2013-07-23Fixed #20761 -- Fixed DatabaseError handling in get_or_create and ↵Loic Bistuer
update_or_create.
2013-07-23Fixed #20782 -- qs.values().aggregate() failureAnssi Kääriäinen
In the combination of .values().aggregate() the aggregate_select_mask didn't include the aggregates added. This resulted in bogus query. Thanks to Trac alias debanshuk for report.
2013-07-12Fixed #20429 -- Added QuerySet.update_or_createKarol Sikora
Thanks tunixman for the suggestion and Loic Bistuer for the review.
2013-07-08Fixed #6785 -- Made QuerySet.get() fetch a limited number of rows.Tim Graham
Thanks Patryk Zawadzki.
2013-07-08A large number of stylistic cleanups across django/db/Alex Gaynor
2013-07-08Removed some logic that wasn't needed following removal of some deprecated code.Alex Gaynor
2013-06-28Removed 'depth' .select_related() argument as per deprecation TL.Ramiro Morales
2013-06-28Support 'pyformat' style parameters in raw queries, Refs #10070Shai Berger
Add support for Oracle, fix an issue with the repr of RawQuerySet, add tests and documentations. Also added a 'supports_paramstyle_pyformat' database feature, True by default, False for SQLite. Thanks Donald Stufft for review of documentation.
2013-05-30Fixed #16856 - Added a way to clear select_related.Tim Graham
Thanks Carl for the suggestion and David Cramer for the patch.
2013-05-27Fixed #16137 - Removed kwargs requirement for QuerySet.get_or_createTim Graham
Thanks wilfred@, poirier, and charettes for work on the patch.
2013-05-26Replaced `and...or...` constructs with PEP 308 conditional expressions.Ramiro Morales