Opened 4 years ago

Closed 4 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 4 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 4 years ago by Sebastian Steins

On sqlite3 backend, the error will be:

InterfaceError: Error binding parameter 1 - probably unsupported type.

comment:2 Changed 4 years ago by Tim Graham

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Can reproduce with the attached test.

Changed 4 years ago by Tim Graham

Attachment: 24608-test.diff added

comment:3 Changed 4 years ago by Tim Graham

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