Opened 10 years ago
Closed 10 years ago
#24608 closed Bug (duplicate)
Chaining inherited models with UUID primary key does not work in MySQL
Reported by: | Sebastian Steins | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Release blocker | Keywords: | mysql uuid |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Consider this models:
class XYZ(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) t = models.PositiveSmallIntegerField(default=1) class ABC(XYZ): t2 = models.PositiveSmallIntegerField(default=2) class DEF(ABC): t3 = models.PositiveSmallIntegerField(default=3)
When running this code
a=ADEF(t3=4) a.save()
everything is ok.
However, calling a.save a second time will cause:
IntegrityError: (1062, "Duplicate entry '51a29210bbe64e13af5786968b54046a' for key 'PRIMARY'")
on a MySQL host.
Attachments (1)
Change History (4)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
Can reproduce with the attached test.
by , 10 years ago
Attachment: | 24608-test.diff added |
---|
comment:3 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Seems to be fixed by #24611 which has a patch.
Note:
See TracTickets
for help on using tickets.
On sqlite3 backend, the error will be: