From 836894f27a0e2c32dbbecbe8392ba7d4d0d17d8a Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Tue, 6 May 2025 09:07:55 -0400 Subject: [PATCH] Refs #470 -- Adjusted Field.db_returning to be backend agnostic. Determining if a field is db_returning based on the default connection feature availability prevents the usage of RETURNING for db_default fields in setups where non-default backends do support RETURNING. Whether or not the field should be attempted to be returned is already checked at the compiler level which is backend aware. --- django/db/models/fields/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index e7add282a6..ee7a30cc30 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -932,9 +932,7 @@ class Field(RegisterLookupMixin): @property def db_returning(self): """Private API intended only to be used by Django itself.""" - return ( - self.has_db_default() and connection.features.can_return_columns_from_insert - ) + return self.has_db_default() def set_attributes_from_name(self, name): self.name = self.name or name