summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
AgeCommit message (Collapse)Author
2023-02-01[4.2.x] Refs #33476 -- Applied Black's 2023 stable style.David Smith
Black 23.1.0 is released which, as the first release of the year, introduces the 2023 stable style. This incorporates most of last year's preview style. https://github.com/psf/black/releases/tag/23.1.0 Backport of 097e3a70c1481ee7b042b2edd91b2be86fb7b5b6 from main
2022-11-23Fixed #31679 -- Delayed annotating aggregations.Simon Charette
By avoiding to annotate aggregations meant to be possibly pushed to an outer query until their references are resolved it is possible to aggregate over a query with the same alias. Even if #34176 is a convoluted case to support, this refactor seems worth it given the reduction in complexity it brings with regards to annotation removal when performing a subquery pushdown.
2022-11-22Fixed #34171 -- Fixed QuerySet.bulk_create() on fields with db_column in ↵DevilsAutumn
unique_fields/update_fields. Bug in 0f6946495a8ec955b471ca1baaf408ceb53d4796. Thanks Joshua Brooks for the report.
2022-11-22Fixed #34177 -- Fixed QuerySet.bulk_create() crash on "pk" in unique_fields.Mariusz Felisiak
Bug in 0f6946495a8ec955b471ca1baaf408ceb53d4796.
2022-11-04Fixed #27654 -- Propagated alters_data attribute to callables overridden in ↵LightDiscord
subclasses. Thanks Shai Berger and Adam Johnson for reviews and the implementation idea.
2022-09-30Fixed #32095 -- Made QuerySet.update_or_create() save only fields passed in ↵sarahboyce
defaults or with custom pre_save(). Thanks Florian Apolloner for the initial patch.
2022-06-23Fixed #33799, Refs #31685 -- Added parameters for updating conflicts to ↵DhruvaPatil98
QuerySeta.abulk_create().
2022-06-17Fixed #28897 -- Fixed QuerySet.update() on querysets ordered by annotations.David Wobrock
2022-06-14Fixed #33772 -- Added QuerySet.first()/last() error message on unordered ↵Pablo Pissi
queryset with aggregation.
2022-06-13Made QuerySet.bulk_update() raise an error when batch_size is zero.Ebram Shehata
2022-05-04Refs #33646 -- Reduced sync_to_async hops on async QuerySet iteration.Simon Charette
Until we add support for truly asynchronous database backends it's actually detrimental to have complete set retrieval require multiple hops between sync and async emulated contexts via asgiref. By defaulting to sending the whole sync _fetch_all() to the current context thread pool we reduce unncessary work when dealing with large result sets since the queryset cannot be iterated anyway before all results are retrieved and cached.
2022-05-02Refs #33646 -- Made QuerySet.raw() async-compatible.Mariusz Felisiak
2022-05-02Refs #33646 -- Added RawModelIterable.Mariusz Felisiak
2022-04-26Fixed #33646 -- Added async-compatible interface to QuerySet.Andrew Godwin
Thanks Simon Charette for reviews. Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2022-03-04Fixed #29865 -- Added logical XOR support for Q() and querysets.Ryan Heard
2022-02-09Fixed #33506 -- Made QuerySet.bulk_update() perform atomic writes against ↵Simon Charette
write database. The lack of _for_write = True assignment in bulk_update prior to accessing self.db resulted in the db_for_read database being used to wrap batched UPDATEs in a transaction. Also tweaked the batch queryset creation to also ensure they are executed against the same database as the opened transaction under all circumstances. Refs #23646, #33501.
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2022-02-03Refs #33476 -- Refactored problematic code before reformatting by Black.Mariusz Felisiak
In these cases Black produces unexpected results, e.g. def make_random_password( self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789', ): or cursor.execute(""" SELECT ... """, [table name], )
2022-01-27Fixed #33463 -- Fixed QuerySet.bulk_update() with F() expressions.Jörg Breitbart
2022-01-25Fixed #29984 -- Added QuerySet.iterator() support for prefetching related ↵Jacob Walls
objects. Co-authored-by: Raphael Kimmig <raphael.kimmig@ampad.de> Co-authored-by: Simon Charette <charette.s@gmail.com>
2022-01-19Fixed #31685 -- Added support for updating conflicts to QuerySet.bulk_create().sean_c_hsu
Thanks Florian Apolloner, Chris Jerdonek, Hannes Ljungberg, Nick Pope, and Mariusz Felisiak for reviews.
2022-01-11Fixed #13251 -- Made pre/post_delete signals dispatch the origin.mgaligniana
2021-11-29Fixed #33322 -- Fixed loss of assigned related object when saving relation ↵Hannes Ljungberg
with bulk_update().
2021-09-24Fixed #33124 -- Avoided accessing the database connections when not necessary.Keryn Knight
Follow up to bf5abf1bdcedb15e949db419c61eeec7c88414ea. This also caches the __getitem__ access.
2021-09-24Fixed #33127 -- Added error messages on | and & operators with combined ↵Hasan Ramezani
querysets.
2021-09-16Fixed #32365 -- Made zoneinfo the default timezone implementation.Carlton Gibson
Thanks to Adam Johnson, Aymeric Augustin, David Smith, Mariusz Felisiak, Nick Pope, and Paul Ganssle for reviews.
2021-08-09Fixed #33003 -- Removed **kwargs from QuerySet._chain().Keryn Knight
The functionality of updating the __dict__ was only present to allow for pickling a Prefetch object, which is a comparably rare operation. Forcing the __getstate__() implementation to handle it allows the chaining operation to be slightly faster, which is much more common.
2021-07-15Refs #32508 -- Raised Type/ValueError instead of using "assert" in ↵Daniyal
django.db.models. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2021-06-30Refs #32786 -- Made Query.clear_ordering() not to cause side effects by default.Hannes Ljungberg
2021-06-29Fixed #32381 -- Made QuerySet.bulk_update() return the number of objects ↵abhiabhi94
updated. Co-authored-by: Diego Lima <diego.lima@lais.huol.ufrn.br>
2021-03-10Refs #32508 -- Raised TypeError instead of using "assert" on unsupported ↵Mariusz Felisiak
operations for sliced querysets.
2021-03-06Fixed #24141 -- Added QuerySet.contains().Johan Schiff
2021-02-11Fixed #32433 -- Added error message on QuerySet.delete() following distinct().Egidijus Macijauskas
2021-01-05Fixed #32231 -- Allowed passing None params to QuerySet.raw().Alexander Lyabah
2020-12-16Fixed #32089 -- Fixed prefetch_related_objects() when some objects are ↵Alexey Nigin
already fetched. Thanks Dennis Kliban for the report and Adam Johnson for the initial patch. Co-authored-by: Adam Johnson <me@adamj.eu>
2020-10-28Made small readability improvements.Martin Thoma
2020-10-26Fixed #29497 -- Fixed loss of assigned parent when saving child with ↵Hannes Ljungberg
bulk_create() after parent.
2020-10-19Fixed #32116 -- Fixed QuerySet.order_by() crash on EmptyQuerySet with ↵Hannes Ljungberg
union() on a single non-empty ordered queryset.
2020-10-05Fixed #32068 -- Added error messages on get() with filters following ↵Hasan Ramezani
union(), intersection(), and difference().
2020-09-29Fixed #31880 -- Made QuerySet.aggregate() raise FieldError when aggregating ↵David Wobrock
over aggregation aliases.
2020-09-16Fixed #31843 -- Fixed pickling named values from QuerySet.values_list().Kwist
2020-09-14Fixed #31990 -- Fixed QuerySet.ordered for GROUP BY queries on models with ↵Mariusz Felisiak
Meta.ordering. Regression in 0ddb4ebf7bfcc4730c80a772dd146a49ef6895f6. Thanks Julien Dutriaux for the report.
2020-09-11Fixed #31943 -- Fixed recreating QuerySet.values()/values_list() when using ↵Hasan Ramezani
a pickled Query.
2020-08-27Fixed #31947 -- Made QuerySet.update_or_create() reuse get_or_create().Alexander
2020-08-26Fixed #31918 -- Allowed QuerySet.in_bulk() to fetch on a single distinct field.Kaustubh
2020-07-31Fixed #27719 -- Added QuerySet.alias() to allow creating reusable aliases.Alexandr Tatarinov
QuerySet.alias() allows creating reusable aliases for expressions that don't need to be selected but are used for filtering, ordering, or as a part of complex expressions. Thanks Simon Charette for reviews.
2020-07-29Fixed #31783 -- Fixed crash when filtering againts "negate" field.Hasan Ramezani
Thanks Simon Charette for the initial patch.
2020-05-21Fixed #30375 -- Added FOR NO KEY UPDATE support to ↵Manuel Weitzman
QuerySet.select_for_update() on PostgreSQL.
2020-05-13Fixed #31580 -- Added error messages on distinct() following union(), ↵Hasan Ramezani
intersection(), and difference().