summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/aggregates
AgeCommit message (Collapse)Author
2026-04-18Fixed #37028 -- Added BitAnd(), BitOr(), and BitXor() aggregates.Mariusz Felisiak
2025-12-02Refs #35444 -- Fixed typo in PostgreSQL StringAgg deprecation warning.Νικόλαος-Διγενής Καραγιάννης
2025-09-17Refs #35444 -- Removed contrib.postgres aggregates ordering kwarg per ↵Jacob Walls
deprecation timeline.
2025-04-16Americanized some spellings.Adam Johnson
2025-03-03Refs #35444 -- Deprecated contrib.postgres.OrderableAggMixin.Chris Muthig
This commit does not create any functional changes, but marks the existing `OrderableAggMixin` class as deprecated so that developers using it directly can be made aware of its future removal.
2025-03-03Fixed #35444 -- Added generic support for Aggregate.order_by.Chris Muthig
This moves the behaviors of `order_by` used in Postgres aggregates into the `Aggregate` class. This allows for creating aggregate functions that support this behavior across all database engines. This is shown by moving the `StringAgg` class into the shared `aggregates` module and adding support for all databases. The Postgres `StringAgg` class is now a thin wrapper on the new shared `StringAgg` class. Thank you Simon Charette for the review.
2025-01-06Refs #35444 -- Deprecated contrib.postgres aggregates ordering for order_by.Chris Muthig
Aligns the argument with SQL standards already used in Window.order_by and sets up for adding support to Aggregate.
2024-04-25Fixed #35339 -- Fixed PostgreSQL aggregate's filter and order_by params order.Chris Muthig
Updated OrderableAggMixin.as_sql() to separate the order_by parameters from the filter parameters. Previously, the parameters and SQL were calculated by the Aggregate parent class, resulting in a mixture of order_by and filter parameters. Thanks Simon Charette for the review.
2024-04-25Refs #35339 -- Updated Aggregate class to return consistent source expressions.Chris Muthig
Refactored the filter and order_by expressions in the Aggregate class to return a list of Expression (or None) values, ensuring that the list item is always available and represents the filter expression. For the PostgreSQL OrderableAggMixin, the returned list will always include the filter and the order_by value as the last two elements. Lastly, emtpy Q objects passed directly into aggregate objects using Aggregate.filter in admin facets are filtered out when resolving the expression to avoid errors in get_refs(). Thanks Simon Charette for the review.
2023-12-29Refs #35064 -- Made OrderableAggMixin avoid creating empty OrderByList.Simon Charette
This paves the way for making OrderByList a simple shim over ExpressionList which requires at least a single item to be provided.
2023-09-18Refs #33308 -- Removed support for passing encoded JSON string literals to ↵Mariusz Felisiak
JSONField & co. Per deprecation timeline.
2023-01-17Refs #10929 -- Stopped forcing empty result value by PostgreSQL aggregates.Mariusz Felisiak
Per deprecation timeline.
2022-12-01Refs #33308 -- Deprecated support for passing encoded JSON string literals ↵Simon Charette
to JSONField & co. JSON should be provided as literal Python objects an not in their encoded string literal forms.
2022-09-17Fixed #34016 -- Fixed QuerySet.values()/values_list() crash on ArrayAgg() ↵Alexander Kerkum
and JSONBAgg(). Regression in e06dc4571ea9fd5723c8029959b95808be9f8812.
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-11-23Refs #33304 -- Enclosed aggregate ordering logic in an expression.Simon Charette
This greatly simplifies the implementation of contrib.postgres' OrderableAggMixin and allows for reuse in Window expressions.
2021-11-04Fixed #33262 -- Fixed crash of conditional aggregation on Exists().Hannes Ljungberg
2021-10-01Fixed #32961 -- Added BitXor() aggregate to django.contrib.postgres.Nick Pope
2021-09-29Fixed #33141 -- Renamed Expression.empty_aggregate_value to ↵David Wobrock
empty_result_set_value.
2021-09-27Fixed #33114 -- Defined default output_field of StringAgg.ali
Thanks Simon Charette for the review.
2021-07-19Refs #10929 -- Deprecated forced empty result value for PostgreSQL aggregates.Nick Pope
This deprecates forcing a return value for ArrayAgg, JSONBAgg, and StringAgg when there are no rows in the query. Now that we have a ``default`` argument for aggregates, we want to revert to returning the default of ``None`` which most aggregate functions return and leave it up to the user to decide what they want to be returned by default.
2021-07-19Fixed #10929 -- Added default argument to aggregates.Nick Pope
Thanks to Simon Charette and Adam Johnson for the reviews.
2021-07-02Refs #26430 -- Re-introduced empty aggregation optimization.Simon Charette
The introduction of the Expression.empty_aggregate_value interface allows the compilation stage to enable the EmptyResultSet optimization if all the aggregates expressions implement it. This also removes unnecessary RegrCount/Count.convert_value() methods. Disabling the empty result set aggregation optimization when it wasn't appropriate prevented None returned for a Count aggregation value. Thanks Nick Pope for the review.
2020-11-04Fixed #32169 -- Added distinct support to JSONBAgg.Artur Beltsov
2020-10-14Refs #32096 -- Fixed crash of ArrayAgg/StringAgg/JSONBAgg with ordering over ↵Mariusz Felisiak
JSONField key transforms. Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd. Thanks Igor Jerosimić for the report.
2020-08-28Fixed #31956 -- Fixed crash of ordering by JSONField with a custom decoder ↵Mariusz Felisiak
on PostgreSQL. Thanks Marc Debureaux for the report. Thanks Simon Charette, Nick Pope, and Adam Johnson for reviews.
2020-07-21Refs #31720 -- Defined default output_field of BoolAnd() and BoolOr() ↵David Chorpash
aggregate functions.
2020-06-13Fixed #31691 -- Added ordering support to JSONBAgg.John Parton
2020-05-08Fixed #12990, Refs #27694 -- Added JSONField model field.sage
Thanks to Adam Johnson, Carlton Gibson, Mariusz Felisiak, and Raphael Michel for mentoring this Google Summer of Code 2019 project and everyone else who helped with the patch. Special thanks to Mads Jensen, Nick Pope, and Simon Charette for extensive reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-02-04Simplified imports from django.db and django.contrib.gis.db.Nick Pope
2020-02-03Fixed CVE-2020-7471 -- Properly escaped StringAgg(delimiter) parameter.Simon Charette
2019-12-31Fixed #31097 -- Fixed crash of ArrayAgg and StringAgg with filter when used ↵David Wobrock
in Subquery.
2019-08-08Removed unnecessary StatAggregate.resolve_expression().Jon Dufresne
This method only calls the parent method, but without the for_save argument. The parent class, Aggregate, already ignores the for_save argument so there is no need for special handling. Unnecessary since its introduction in e4cf8c8420634d6f2dc8ce873246256ce635972d.
2019-05-28Fixed #30315 -- Fixed crash of ArrayAgg and StringAgg with ordering when ↵Caio Ariede
used in Subquery.
2019-04-06Fixed #30332 -- Fixed crash of ordering by expressions with params in ↵Simone Pellizzari
ArrayAgg and StringAgg.
2019-01-09Fixed #28658 -- Added DISTINCT handling to the Aggregate class.Simon Charette
2018-06-28Fixed #26067 -- Added ordering support to ArrayAgg and StringAgg.Floris den Hengst
2017-12-30Fixed #28908 -- Allowed ArrayField lookups on ArrayAgg annotations.Sergey Fedoseev
2017-09-16Simplified Count.convert_value() and RegrCount.convert_value().Sergey Fedoseev
2017-09-11Fixed #28492 -- Defined default output_field of expressions at the class level.Simon Charette
This wasn't possible when settings were accessed during Field initialization time as our test suite setup script was triggering imports of expressions before settings were configured.
2017-08-12Fixed #27849 -- Added filtering support to aggregates.Tom
2017-07-20Fixed #28370 -- Deprecated the context arg of Field.from_db_value() and ↵Tim Graham
Expression.convert_value(). Unused since a0d166306fbdc41f49e6fadf4ec84b17eb147daa.
2017-07-14Fixed #28394 -- Allowed setting BaseExpression.output_field (renamed from ↵Sergey Fedoseev
_output_field).
2017-03-23Simplified handling of expressions in StatAggregate.Sergey Fedoseev
2017-02-04Fixed #27767 -- Added distinct argument to ArrayAgg.orf
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2016-11-28Refs #26327 -- Renamed JsonAgg to JSONBAgg.Mads Jensen
Thanks to Christian von Roques for the report.
2016-10-07Fixed #26327 -- Added JsonAgg to contrib.postgres.Mads Jensen
Thanks Tim Graham for review.
2016-06-02Fixed #26617 -- Added distinct argument to contrib.postgres's StringAgg.Rustam Kashapov
2015-03-30Fixed #24301 -- Added PostgreSQL-specific aggregate functionsAndriy Sokolovskiy