#34131: Postgres AutoField change from serial to identity
-------------------------------------+-------------------------------------
     Reporter:  Marco Glauser        |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 I'm afraid that without `contrib.postgres` support for serial fields
 (#27452) or database level defaults (#470) this will be hard to solve.

 The only way I can see around that is in the mean type is to drop the
 identity on the column and entirely and re-create it as a serial with
 something along the lines of

 {{{#!sql
 ALTER TABLE invoice_invoice ALTER COLUMN id DROP IDENTITY;
 CREATE SEQUENCE invoice_invoice_id_seq OWNED BY invoice_invoice.id;
 ALTER TABLE invoice_invoice ALTER COLUMN id SET DEFAULT
 luhn_generate(nextval('invoice_invoice_id_seq'));
 }}}

 I wonder if this should be considered a release blocker since it could be
 considered a bug in feature introduced in 4.1. It's a convoluted use case
 that does have a workaround though so I'm not entirely convinced.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34131#comment:1>
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/0107018436a1f3c7-2681858c-8804-4590-9f01-8e663b5deb66-000000%40eu-central-1.amazonses.com.

Reply via email to