Opened 9 years ago

Closed 9 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)

24608-test.diff (1.1 KB ) - added by Tim Graham 9 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by Sebastian Steins, 9 years ago

On sqlite3 backend, the error will be:

InterfaceError: Error binding parameter 1 - probably unsupported type.

comment:2 by Tim Graham, 9 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Can reproduce with the attached test.

by Tim Graham, 9 years ago

Attachment: 24608-test.diff added

comment:3 by Tim Graham, 9 years ago

Resolution: duplicate
Status: newclosed

Seems to be fixed by #24611 which has a patch.

Note: See TracTickets for help on using tickets.
Back to Top