Re: [Django] #34058: Widening AutoField to BigAutoField, fails to widen the sequence.

6 views
Skip to first unread message

Django

unread,
Sep 29, 2022, 3:37:49 AM9/29/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Mariusz Felisiak
* status: new => assigned


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

Django

unread,
Sep 29, 2022, 6:01:36 AM9/29/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_docs: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

[https://github.com/django/django/pull/16134 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:3>

Django

unread,
Sep 29, 2022, 6:32:35 AM9/29/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_docs: 1 => 0
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:4>

Django

unread,
Sep 29, 2022, 7:20:37 AM9/29/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed

Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"19e6efa50b603af325e7f62058364f278596758f" 19e6efa5]:
{{{
#!CommitTicketReference repository=""
revision="19e6efa50b603af325e7f62058364f278596758f"
Fixed #34058 -- Changed sequence types when altering pre-Django 4.1 auto
fields on PostgreSQL.

Thanks Anders Kaseorg for the report.

Thanks Florian Apolloner for pair programming.

Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:5>

Django

unread,
Sep 29, 2022, 7:21:49 AM9/29/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"97353bc64baca2affe6be6a0c4e5c3cc1de496ec" 97353bc6]:
{{{
#!CommitTicketReference repository=""
revision="97353bc64baca2affe6be6a0c4e5c3cc1de496ec"
[4.1.x] Fixed #34058 -- Changed sequence types when altering pre-Django


4.1 auto fields on PostgreSQL.

Thanks Anders Kaseorg for the report.

Thanks Florian Apolloner for pair programming.

Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.
Backport of 19e6efa50b603af325e7f62058364f278596758f from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:6>

Django

unread,
Sep 29, 2022, 5:47:42 PM9/29/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Anders Kaseorg):

I found a scenario in which this fix doesn’t work: if the field had been
renamed before the upgrade, the corresponding sequence will not have been
renamed.

To modify my above reproduction recipe, insert a new step between steps 3
and 4 renaming the field:

{{{
#!python
# my_app/models.py
from django.db import models
class Widget(models.Model):
renamed_id = models.SmallAutoField(primary_key=True)
}}}

{{{
#!console
$ ./manage.py makemigrations
Was widget.id renamed to widget.renamed_id (a SmallAutoField)? [y/N] y
Migrations for 'my_app':
my_app/migrations/0002_rename_id_widget_renamed_id.py
- Rename field id on widget to renamed_id
$ ./manage.py migrate
Operations to perform:
Apply all migrations: my_app
Running migrations:
Applying my_app.0002_rename_id_widget_renamed_id... OK
}}}

(and then keep the new name in step 5).

--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:7>

Django

unread,
Sep 30, 2022, 1:48:45 AM9/30/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:7 Anders Kaseorg]:


> I found a scenario in which this fix doesn’t work: if the field had been
renamed before the upgrade, the corresponding sequence will not have been
renamed.
>
> To modify my above reproduction recipe, insert a new step between steps
3 and 4 renaming the field:
>
> {{{
> #!python
> # my_app/models.py
> from django.db import models
> class Widget(models.Model):
> renamed_id = models.SmallAutoField(primary_key=True)
> }}}
>
> {{{
> #!console
> $ ./manage.py makemigrations
> Was widget.id renamed to widget.renamed_id (a SmallAutoField)? [y/N] y
> Migrations for 'my_app':
> my_app/migrations/0002_rename_id_widget_renamed_id.py
> - Rename field id on widget to renamed_id
> $ ./manage.py migrate
> Operations to perform:
> Apply all migrations: my_app
> Running migrations:
> Applying my_app.0002_rename_id_widget_renamed_id... OK
> }}}
>
> (and then keep the new name in step 5).

Good catch! It's partly
[https://github.com/django/django/blob/4a30e0db269a364cb480f48524fa48e6abcf9e94/django/db/backends/postgresql/schema.py#L128-L152
a long-standing issue], however, IMO, we should backport
[https://github.com/django/django/pull/16138 the fix].

--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:8>

Django

unread,
Oct 1, 2022, 1:54:30 AM10/1/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"bc3b8f152452ba0e41f28baa93c0bf8f39cddb09" bc3b8f1]:
{{{
#!CommitTicketReference repository=""
revision="bc3b8f152452ba0e41f28baa93c0bf8f39cddb09"
Refs #34058 -- Fixed changing/deleting sequences when altering pre-Django


4.1 auto fields on PostgreSQL.

Thanks Anders Kaseorg for the report.

Follow up to 19e6efa50b603af325e7f62058364f278596758f.
Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:9>

Django

unread,
Oct 1, 2022, 2:00:29 AM10/1/22
to django-...@googlegroups.com
#34058: Widening AutoField to BigAutoField, fails to widen the sequence.
-------------------------------------+-------------------------------------
Reporter: Anders Kaseorg | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"96c541ecef98e2b93db8eba144be2d8c48e6c2cf" 96c541e]:
{{{
#!CommitTicketReference repository=""
revision="96c541ecef98e2b93db8eba144be2d8c48e6c2cf"
[4.1.x] Refs #34058 -- Fixed changing/deleting sequences when altering


pre-Django 4.1 auto fields on PostgreSQL.

Thanks Anders Kaseorg for the report.

Follow up to 19e6efa50b603af325e7f62058364f278596758f.
Regression in 2eea361eff58dd98c409c5227064b901f41bd0d6.

Backport of bc3b8f152452ba0e41f28baa93c0bf8f39cddb09 from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34058#comment:10>

Reply all
Reply to author
Forward
0 new messages