[Django] #27338: Running an AlterField to change a CharField primary key to AutoField crashes

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #27338: Running an AlterField to change a CharField primary key to AutoField crashes

Django
#27338: Running an AlterField to change a CharField primary key to AutoField
crashes
------------------------------------------------+------------------------
               Reporter:  Tim Graham            |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Migrations            |        Version:  master
               Severity:  Normal                |       Keywords:
           Triage Stage:  Accepted              |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 For example: change `id = models.CharField(max_length=20,
 primary_key=True)` to `id = models.AutoField(primary_key=True)`. It
 generates this operation:
 {{{
 migrations.AlterField(
     model_name='foo',
     name='id',
     field=models.AutoField(primary_key=True, serialize=False),
 ),
 }}}
 Running it on PostgreSQ gives: `django.db.utils.ProgrammingError: operator
 class "varchar_pattern_ops" does not accept data type integer`. I'm not
 sure if this can be made to work sensibly. Is it possible to autopopulate
 the `AutoField`? I ran into this situation while investigating #27267.

--
Ticket URL: <https://code.djangoproject.com/ticket/27338>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.36bf92ab9d12806a41dd566a1f6841a9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #27338: Running an AlterField to change a CharField primary key to AutoField crashes

Django
#27338: Running an AlterField to change a CharField primary key to AutoField
crashes
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Migrations            |                  Version:  master
     Severity:  Normal                |               Resolution:
     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 Tim Graham):

 #27339 is related.

--
Ticket URL: <https://code.djangoproject.com/ticket/27338#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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.2905c57973a7130873b57d9ddc514ce5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #27338: Running an AlterField to change a CharField primary key to AutoField crashes

Django
In reply to this post by Django
#27338: Running an AlterField to change a CharField primary key to AutoField
crashes
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Migrations            |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Description changed by Mads Jensen:

Old description:

> For example: change `id = models.CharField(max_length=20,
> primary_key=True)` to `id = models.AutoField(primary_key=True)`. It
> generates this operation:
> {{{
> migrations.AlterField(
>     model_name='foo',
>     name='id',
>     field=models.AutoField(primary_key=True, serialize=False),
> ),
> }}}
> Running it on PostgreSQ gives: `django.db.utils.ProgrammingError:
> operator class "varchar_pattern_ops" does not accept data type integer`.
> I'm not sure if this can be made to work sensibly. Is it possible to
> autopopulate the `AutoField`? I ran into this situation while
> investigating #27267.
New description:

 For example: change `id = models.CharField(max_length=20,
 primary_key=True)` to `id = models.AutoField(primary_key=True)`. It
 generates this operation:
 {{{
 migrations.AlterField(
     model_name='foo',
     name='id',
     field=models.AutoField(primary_key=True, serialize=False),
 ),
 }}}
 Running it on PostgreSQL gives: `django.db.utils.ProgrammingError:
 operator class "varchar_pattern_ops" does not accept data type integer`.
 I'm not sure if this can be made to work sensibly. Is it possible to
 autopopulate the `AutoField`? I ran into this situation while
 investigating #27267.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27338#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.9e50a1ab6ceef4378fd7d3e3ff1d760b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #27338: Running an AlterField to change a CharField primary key to AutoField crashes

Django
In reply to this post by Django
#27338: Running an AlterField to change a CharField primary key to AutoField
crashes
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Migrations            |                  Version:  master
     Severity:  Normal                |               Resolution:
     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 Nathan Self):

 PostgreSQL gives the same error if you use AlterField to change a
 CharField primary key to a ForeignKey.

--
Ticket URL: <https://code.djangoproject.com/ticket/27338#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.a6c8e41b3d301c21b2d261dd12984fc4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #27338: Running an AlterField to change a CharField primary key to AutoField crashes

Django
In reply to this post by Django
#27338: Running an AlterField to change a CharField primary key to AutoField
crashes
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Migrations            |                  Version:  master
     Severity:  Normal                |               Resolution:
     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 GitHub <noreply@…>):

 In [changeset:"c8250ef361dcb4c7ed76632e4308c6db22da77d0" c8250ef]:
 {{{
 #!CommitTicketReference repository=""
 revision="c8250ef361dcb4c7ed76632e4308c6db22da77d0"
 Refs #27338 -- Added tests for altering CharField with primary_key=True to
 AutoField on PostgreSQL.

 Fixed in 91b2bc3e70be2632baad86488fb03cf02848b5b6.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27338#comment:4>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.f4322514a8f65a4237d190d3451a3c72%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #27338: Running an AlterField to change a CharField primary key to AutoField crashes. (was: Running an AlterField to change a CharField primary key to AutoField crashes)

Django
In reply to this post by Django
#27338: Running an AlterField to change a CharField primary key to AutoField
crashes.
--------------------------------------+------------------------------------
     Reporter:  Tim Graham            |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  closed
    Component:  Migrations            |                  Version:  master
     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
--------------------------------------+------------------------------------
Changes (by felixxm):

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


Comment:

 Fixed in 91b2bc3e70be2632baad86488fb03cf02848b5b6.

--
Ticket URL: <https://code.djangoproject.com/ticket/27338#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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.37c1f35a79e7d0d54bd4d51032e7432e%40djangoproject.com.