mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Leveraged db_returning to determine fields to insert
This commit is contained in:
parent
f333e3513e
commit
6a9515bcf9
@ -1050,12 +1050,20 @@ class Model(AltersData, metaclass=ModelBase):
|
||||
),
|
||||
)["_order__max"]
|
||||
)
|
||||
returning_fields = meta.db_returning_fields
|
||||
fields = [
|
||||
f
|
||||
for f in meta.local_concrete_fields
|
||||
if not f.generated and (pk_set or f is not meta.auto_field)
|
||||
if not f.generated
|
||||
and (
|
||||
f not in returning_fields
|
||||
or (
|
||||
f.db_default is not NOT_PROVIDED
|
||||
and getattr(self, f.attname) is not f.db_default
|
||||
)
|
||||
or getattr(self, f.attname) is not None
|
||||
)
|
||||
]
|
||||
returning_fields = meta.db_returning_fields
|
||||
results = self._do_insert(
|
||||
cls._base_manager, using, fields, returning_fields, raw
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user