mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +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"]
|
)["_order__max"]
|
||||||
)
|
)
|
||||||
|
returning_fields = meta.db_returning_fields
|
||||||
fields = [
|
fields = [
|
||||||
f
|
f
|
||||||
for f in meta.local_concrete_fields
|
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(
|
results = self._do_insert(
|
||||||
cls._base_manager, using, fields, returning_fields, raw
|
cls._base_manager, using, fields, returning_fields, raw
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user