Re: [Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-27 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
-+-
 Reporter:  Fabio Sangiovanni|Owner:  Jordan
 Type:   |  Bae
  Cleanup/optimization   |   Status:  closed
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

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


Comment:

 In [changeset:"f5a3243911a5c42775cd838a3da1d0f3ac4a74ee" f5a32439]:
 {{{
 #!CommitTicketReference repository=""
 revision="f5a3243911a5c42775cd838a3da1d0f3ac4a74ee"
 Fixed #33125 -- Avoided redundant unique constraint when converting a non-
 unique field to primary key on MySQL and PostgreSQL.
 }}}

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.07264563cd25c5b887618e4d83549441%40djangoproject.com.


Re: [Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-27 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
-+-
 Reporter:  Fabio Sangiovanni|Owner:  Jordan
 Type:   |  Bae
  Cleanup/optimization   |   Status:  assigned
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * stage:  Accepted => Ready for checkin


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.1039cf745d2e6050767d3cdc46c6fd73%40djangoproject.com.


Re: [Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-27 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
-+-
 Reporter:  Fabio Sangiovanni|Owner:  Jordan
 Type:   |  Bae
  Cleanup/optimization   |   Status:  assigned
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   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 Jordan Bae):

 * needs_better_patch:  1 => 0
 * needs_tests:  1 => 0


Comment:

 Thank you for reviewing! I updated the code :)

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.34cf65421d42481c66cea60f9ba10a9d%40djangoproject.com.


Re: [Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-27 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
-+-
 Reporter:  Fabio Sangiovanni|Owner:  Jordan
 Type:   |  Bae
  Cleanup/optimization   |   Status:  assigned
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.ad9f2caad4a373b5066af440d4d7ceea%40djangoproject.com.


Re: [Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-25 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
-+-
 Reporter:  Fabio Sangiovanni|Owner:  Jordan
 Type:   |  Bae
  Cleanup/optimization   |   Status:  assigned
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   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 Jordan Bae):

 * has_patch:  0 => 1


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.7fa62691935161b4bf20f0d985d7d5c7%40djangoproject.com.


Re: [Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-24 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
-+-
 Reporter:  Fabio Sangiovanni|Owner:  Jordan
 Type:   |  Bae
  Cleanup/optimization   |   Status:  assigned
Component:  Migrations   |  Version:  dev
 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
-+-
Changes (by Jordan Bae):

 * owner:  nobody => Jordan Bae
 * status:  new => assigned


Comment:

 I will make PR for this.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.0579d61345df471f26e9c13e93b2fbe6%40djangoproject.com.


Re: [Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-21 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
--+
 Reporter:  Fabio Sangiovanni |Owner:  nobody
 Type:  Cleanup/optimization  |   Status:  new
Component:  Migrations|  Version:  dev
 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
--+
Changes (by Mariusz Felisiak):

 * type:  Bug => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for the report. We can probably add the same behavior as in #29496
 (see 6dd4edb1b4f5441c5f543e29395039839c50d10b) on Oracle to other
 backends.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.08a805769b4400e6aab26a12eebca01a%40djangoproject.com.


[Django] #33125: Changing model field to become PK creates redundant UNIQUE constraint

2021-09-21 Thread Django
#33125: Changing model field to become PK creates redundant UNIQUE constraint
-+
   Reporter:  Fabio Sangiovanni  |  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  Migrations |Version:  dev
   Severity:  Normal |   Keywords:
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+
 Hi,

 when swapping the `primary_key=True` attribute between two model fields,
 `migrations.AlterField` seems to generate a redundant UNIQUE constraint
 involving the new PK field.

 To reproduce:

 Prerequisites:

 PostgreSQL 11.12
 Python 3.8
 Django main@7d909b2282c91c5bc5204dd160412e90fa86d624

 Before state:


 {{{
 class Pony(models.Model):
 name = models.CharField(max_length=32, primary_key=True)
 nickname = models.CharField(max_length=32)
 }}}


 sqlmigrate:

 {{{
 BEGIN;
 --
 -- Create model Pony
 --
 CREATE TABLE "app_pony" ("name" varchar(32) NOT NULL PRIMARY KEY,
 "nickname" varchar(32) NOT NULL);
 CREATE INDEX "app_pony_name_204da2d2_like" ON "app_pony" ("name"
 varchar_pattern_ops);
 COMMIT;
 }}}

 After state:

 {{{
 class Pony(models.Model):
 name = models.CharField(max_length=32)
 nickname = models.CharField(max_length=32, primary_key=True)
 }}}

 sqlmigrate:

 {{{
 BEGIN;
 --
 -- Alter field name on pony
 --
 DROP INDEX IF EXISTS "app_pony_name_204da2d2_like";
 --
 -- Alter field nickname on pony
 --
 ALTER TABLE "app_pony" ADD CONSTRAINT "app_pony_nickname_1b2a0f82_uniq"
 UNIQUE ("nickname");
 ALTER TABLE "app_pony" ADD CONSTRAINT "app_pony_nickname_1b2a0f82_pk"
 PRIMARY KEY ("nickname");
 CREATE INDEX "app_pony_nickname_1b2a0f82_like" ON "app_pony" ("nickname"
 varchar_pattern_ops);
 COMMIT;
 }}}

 The `app_pony_nickname_1b2a0f82_uniq` constraint looks reduntant to me,
 since the `nickname` field is going to become PK anyways.

 Please let me know if I'm missing something or if I can be of further
 help.

 Thanks,

 Fabio

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.eca5ed7945747ebcd0c7fd2f289e5a17%40djangoproject.com.