mirror of
https://github.com/django/django.git
synced 2025-08-30 23:37:50 +00:00
Refs #29444 -- Allowed returning multiple fields from INSERT statements on PostgreSQL.
Thanks Florian Apolloner, Tim Graham, Simon Charette, Nick Pope, and Mariusz Felisiak for reviews.
This commit is contained in:
parent
736e7d44de
commit
7254f1138d
16 changed files with 209 additions and 89 deletions
|
@ -4,6 +4,7 @@ Various complex queries that have been problematic in the past.
|
|||
import threading
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.functions import Now
|
||||
|
||||
|
||||
class DumbCategory(models.Model):
|
||||
|
@ -730,3 +731,19 @@ class RelatedIndividual(models.Model):
|
|||
class CustomDbColumn(models.Model):
|
||||
custom_column = models.IntegerField(db_column='custom_name', null=True)
|
||||
ip_address = models.GenericIPAddressField(null=True)
|
||||
|
||||
|
||||
class CreatedField(models.DateTimeField):
|
||||
db_returning = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.setdefault('default', Now)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class ReturningModel(models.Model):
|
||||
created = CreatedField(editable=False)
|
||||
|
||||
|
||||
class NonIntegerPKReturningModel(models.Model):
|
||||
created = CreatedField(editable=False, primary_key=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue