#28272: PostgreSQL: AutoField sequences don't increment when inserting objects 
with
an explicitely specified PK
-------------------------------------+-------------------------------------
     Reporter:  François Freitag     |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  postgresql sequence  |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by François Freitag):

 I do not think that manually specifying PK is a good idea, and I agree
 that resetting the sequence is subject to race conditions and might not be
 a good idea.

 I think we should at least update the documentation to make it clear that
 specifying pk in {{{create}}} or {{{bulk_create}}} can lead to future
 issues on PostgreSQL. The documentation already states:

     Explicitly specifying auto-primary-key values is mostly useful for
 bulk-saving objects, when you’re confident you won’t have primary-key
 collision.

 I think manually setting primary keys on PostgreSQL should discouraged, or
 a link to sqlresetsequence should be added (even though using this
 management command seem like a very manual process).

--
Ticket URL: <https://code.djangoproject.com/ticket/28272#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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.873863a8231037ba6ad084d9636b2aab%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to