#24042: Custom AutoField fields do not work correctly on postgres
-------------------------------------+-------------------------------------
     Reporter:  Lucas Wiman          |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Nick Pope):

 Replying to [comment:4 felixxm]:
 > Agreed. Creating custom auto fields should be possible with the
 `db_returning` flag.

 I'm not entirely convinced that everything has been resolved here. Is
 `db_returning` enough?

 After digging, the issue was that a custom text-based field was being used
 and `AutoField` wasn't being subclassed.

 `AutoField` is essentially `IntegerField` with some additional bits on
 top. Hence the refactoring in #29979 to segregate out the bits that make
 it an auto-field and to correct the inheritance from the appropriate field
 for the desired data type. The next stage was to work toward making `class
 TextAutoField(AutoFieldMixin, TextField):` or `class
 UUIDAutoField(AutoFieldMixin, UUIDField):` workable. This ticket was about
 replacing all of the `isinstance(..., AutoField)` checks to use some
 property such as `db_generated` and/or `is_auto`. See the unfinished
 [https://github.com/django/django/pull/3776 PR].

 Eventually we could decide to deprecate inheritance from `AutoField`
 itself which has always been more tightly coupled with integer-based auto-
 fields.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/24042#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.36440c250019ecadde12ed84edc51dbf%40djangoproject.com.

Reply via email to