summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql
AgeCommit message (Collapse)Author
2026-04-30Fixed #37075 -- Allowed overriding the PostgreSQL pool's "check" callable.HEADmaininitial-branchRaoni Timo
Setting "check" in OPTIONS["pool"] previously raised TypeError because the PostgreSQL backend always passed check= to ConnectionPool() and unpacked **pool_options on top, regardless of CONN_HEALTH_CHECKS. The user's callable now takes precedence via setdefault(); pool_options is copied first to avoid mutating the user's settings dict.
2026-03-20Fixed #36960 -- Enabled the use of psycopg 3's optimized timestamp loader.Aarni Koskela
Based on Daniele Varrazzo's comment in https://github.com/psycopg/psycopg/issues/1273#issuecomment-3986829769
2026-03-19Refs #36795 -- Removed unnecessary prohibits_dollar_signs_in_column_aliases ↵Simon Charette
feature flag. Now that user provided aliases are systematically quoted there is no need to disallow the usage of the dollar sign on Postgres.
2026-03-12Fixed #36727 -- Deprecated Field.get_placeholder in favor of ↵Simon Charette
get_placeholder_sql. The lack of ability of the get_placeholder call chain to return SQL and parameters separated so they can be mogrified by the backend at execution time forced implementations to dangerously interpolate potentially user controlled values. The get_placeholder_sql name was chosen due to its proximity to the previous method, but other options such as Field.as_sql were considered but ultimately rejected due to its different input signature compared to Expression.as_sql that might have lead to confusion. There is a lot of overlap between what Field.get_db_prep_value and get_placeholder_sql do but folding the latter in the former would require changing its return signature to return expression which is a way more invasive change than what is proposed here. Given we always call get_db_prep_value it might still be an avenue worth exploring in the future to offer a publicly documented interface to allow field to take an active part in the compilation chain. Thanks Jacob for the review.
2026-01-18Applied Black's 2026 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/26.1.0
2026-01-16Fixed #36822 -- Added parameter limit for PostgreSQL with server-side binding.JaeHyuck Sa
2025-12-31Refs #33647 -- Fixed silent data truncation in bulk_create on Postgres.Simon Charette
Regression in a16eedcf9c69d8a11d94cac1811018c5b996d491. The UNNEST strategy is affected by the same problem bulk_update has wrt/ to silent data truncation due to its usage of db_type which always returns a parametrized subtype.
2025-12-26Fixed #36112 -- Added fallback in last_executed_query() on Oracle and ↵VIZZARD-X
PostgreSQL.
2025-12-12Refs #36735 -- Supported shift parameter for UUID7 on PostgreSQL.Lily Acorn
2025-12-12Fixed #36735 -- Added UUID4 and UUID7 database functions.Lily Acorn
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2025-12-04Added DatabaseFeatures.prohibits_dollar_signs_in_column_aliases.Tim Graham
This is also applicable on CockroachDB.
2025-12-02Fixed CVE-2025-13372 -- Protected FilteredRelation against SQL injection in ↵Jacob Walls
column aliases on PostgreSQL. Follow-up to CVE-2025-57833. Thanks Stackered for the report, and Simon Charette and Mariusz Felisiak for the reviews.
2025-11-20Fixed #36748 -- Filtered non-standard placeholders from UNNEST queries.Chris Wesseling
2025-11-17Fixed #24920 -- Added support for DecimalField with no precision.Mariusz Felisiak
Thanks Lily for the review.
2025-11-14Refs #24928 -- Added introspection support for PostgreSQL HStoreField.Mariusz Felisiak
2025-10-31Fixed #36661 -- Added introspection of database-level delete options.Mariusz Felisiak
2025-10-18Fixed #21961 -- Added support for database-level delete options for ForeignKey.Mariusz Felisiak
Thanks Simon Charette for pair programming. Co-authored-by: Nick Stefan <NickStefan12@gmail.com> Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com> Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-10-16Bumped minimum isort version to 7.0.0.Jacob Walls
Added ignores relating to https://github.com/PyCQA/isort/issues/2352.
2025-10-03Fixed #36623 -- Dropped support for PostgreSQL 14 and PostGIS 3.1.Mariusz Felisiak
2025-09-29Skipped NOT NULL constraints on PostgreSQL 18+.Mariusz Felisiak
Thanks Simon Charette for the implementation idea.
2025-09-29Fixed #36277 -- Fixed DatabaseFeatures.supports_virtual_generated_columns on ↵arsalan64
PostgreSQL 18+.
2025-09-23Fixed #36616 -- Added DatabaseOperations.adapt_durationfield_value().Tim Graham
2025-09-14Refs #27222 -- Refreshed GeneratedFields values on save() initiated update.Simon Charette
This required implementing UPDATE RETURNING machinery that heavily borrows from the INSERT one.
2025-09-05Fixed #36564 -- Changed DEFAULT_AUTO_FIELD from AutoField to BigAutoField.Tim Graham
2025-08-28Refs #27222 -- Implemented ↵Simon Charette
BaseDatabaseOperations.return_insert_columns()/fetch_returned_insert_rows().
2025-08-12Remove unused OneToOneField from DatabaseWrapper.data_types.Tim Graham
OneToOneField uses the type of the related field.
2025-07-23Refs #36500 -- Rewrapped long docstrings and block comments via a script.django-bot
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
2025-07-10Fixed #36502 -- Restored UNNEST strategy for foreign key bulk inserts on ↵Simon Charette
PostgreSQL. Regression in 764af7a3d6c0b543dcf659a2c327f214da768fe4.
2025-05-20Fixed #34262 -- Added support for AnyValue for SQLite, MySQL, Oracle, and ↵ontowhee
Postgresql 16+. Thanks Simon Charette for the guidance and review. Thanks Tim Schilling for the documentation review. Thanks David Wobrock for investigation and solution proposals.
2025-04-30Refs #36052, #32234 -- Removed create_test_table_with_composite_primary_key ↵Simon Charette
flag in favor of using CompositePrimaryKey. Now that Django properly supports creating models with composite primary keys, the tests should use a `CompositePrimaryKey` field instead of a feature flag to inline backend specific SQL for creating a composite PK. Specifcially, the inspectdb's test_composite_primary_key was adjusted to use schema editor instead of per-backend raw SQL.
2025-04-04Fixed #36289 -- Fixed bulk_create() crash with nullable geometry fields on ↵Simon Charette
PostGIS. Swapped to an allow list instead of a deny list for field types to determine if the UNNEST optimization can be enabled to avoid further surprises with other types that would require further specialization to adapt. Regression in a16eedcf9c69d8a11d94cac1811018c5b996d491. Thanks Joshua Goodwin for the report and Sarah Boyce for the test.
2025-03-31Refs #28909 -- Simplified code using unpacking generalizations.Aarni Koskela
2025-03-05Fixed typo in django/db/backends/postgresql/psycopg_any.py comment.Jacob Walls
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-02-05Fixed #36165 -- Made PostgreSQL's SchemaEditor._delete_index_sql() respect ↵Natalia
the "sql" argument. This is a follow up of bd366ca2aeffa869b7dbc0b0aa01caea75e6dc31. Thank you Daniel Finch for the report.
2025-01-28Refs #36005 -- Bumped minimum supported versions of 3rd-party packages.Mariusz Felisiak
This bumps minimum supported versions of 3rd-party packages to the first releases to support Python 3.12.
2025-01-20Fixed #36107 -- Adjusted UNNEST bulk_create strategy to opt-out sized arrays.Simon Charette
The array fields opt-out heuristic failed to account for sized arrays. Note that we keep relying on db_type as opposed to performing an ArrayField instance check against the column's field as there could be other implementations of model fields that use Postgres arrays to store the optimization must be disabled for all of them. Refs #35936. Thanks Claude Paroz for the report and test.
2024-12-17Fixed #35969 -- Disallowed specifying a USING clause for altered generated ↵lufafajoshua
field. PostgreSQL versions 16.5 and above no longer permit the use of a USING clause when changing the type of a generated column.
2024-12-11Fixed #35936 -- Used unnest for bulk inserts on Postgres when possible.Simon Charette
This should make bulk_create significantly faster on Postgres when provided only literal values. Thanks James Sewell for writing about this technique, Tom Forbes for validating the performance benefits, David Sanders and Mariusz Felisiak for the review.
2024-12-09Refs #35982 -- Made BaseDatabaseOperations.adapt_decimalfield_value() a no-op.Simon Charette
2024-10-31Fixed #35180 -- Recreated PostgreSQL _like indexes when changing between ↵Ben Cail
TextField and CharField field types.
2024-10-30Fixed #35856 -- Added QuerySet.explain() support for MEMORY/SERIALIZE option ↵Anthony Joseph
on PostgreSQL 17+.
2024-08-28Fixed #35688 -- Restored timezone and role setters to be PostgreSQL ↵Sarah Boyce
DatabaseWrapper methods. Following the addition of PostgreSQL connection pool support in Refs #33497, the methods for configuring the database role and timezone were moved to module-level functions. This change prevented subclasses of DatabaseWrapper from overriding these methods as needed, for example, when creating wrappers for other PostgreSQL-based backends. Thank you Christian Hardenberg for the report and to Florian Apolloner and Natalia Bidart for the review. Regression in fad334e1a9b54ea1acb8cce02a25934c5acfe99f. Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-08-01Reverted "Fixed #28646 -- Prevented duplicate index when unique is set to ↵Sarah Boyce
True on PostgreSQL." This reverts commit 9cf9c796be8dd53bc3b11355ff39d65c81d7be6d due to a crash on Oracle as it didn't allow multiple indexes on the same field.
2024-07-30Fixed #28646 -- Prevented duplicate index when unique is set to True on ↵Ben Cail
PostgreSQL.
2024-05-27Fixed #35479 -- Dropped support for PostgreSQL 13 and PostGIS 3.0.Mariusz Felisiak
2024-03-25Removed unused _alter_column_collation_sql() in PostgreSQL DatabaseSchemaEditor.Mariusz Felisiak
Unused since ae0899be0d787fbfc5f5ab2b18c5a8219d822d2b.
2024-03-14Refs #35295 -- Added BaseDatabaseOperations.bulk_insert_sql().Mariusz Felisiak
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2024-03-06Fixed #35021 -- Fixed capturing queries when using client-side parameters ↵Michail Chatzis
binding with psycopg 3+.
2024-03-01Refs #33497 -- Added connection pool support for PostgreSQL.Sarah Boyce
Co-authored-by: Florian Apolloner <florian@apolloner.eu> Co-authored-by: Ran Benita <ran@unusedvar.com>