Opened 14 years ago

Closed 10 years ago

Last modified 10 years ago

#15321 closed Bug (fixed)

Models._get_unique_checks() does not return grandparents' unique checks

Reported by: jku Owned by: aron45
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: models, unique checks
Cc: aron45 Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Consider the following models:

class Project(models.Model):
    title = models.CharField(max_length=255)
    internal_id = models.CharField(max_length=255, unique=True)

class SubProject(Project):
    # ... fields of SubProject ...
    pass

class SubSubProject(SubProject):
    # ... fields of SubSubProject ...
    pass

Following code works as expected (b.full_clean() throws a ValidationError):

a = SubProject( title = 'A', internal_id = 1 )
a.save()
b = SubProject( title = 'B', internal_id = 1 )
b.full_clean() # Throws ValidationError

Following code does not work as expected (b.full_clean() does not throw an exception, b.save() throws an IntegrityError):

a = SubSubProject( title = 'A', internal_id = 2 )
a.save()
b = SubSubProject( title = 'B', internal_id = 2 )
b.full_clean() # Does not throw any exception!
b.save() # Throws IntegrityError, of course!

Attachments (2)

sub_sub_unique_fix (4.1 KB ) - added by sswang 14 years ago.
fix for sub sub inheritance uniqueness
sub_sub_unique_fix.patch (4.1 KB ) - added by sswang 14 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

by sswang, 14 years ago

Attachment: sub_sub_unique_fix added

fix for sub sub inheritance uniqueness

comment:2 by sswang, 14 years ago

Owner: changed from nobody to sswang

comment:3 by sswang, 14 years ago

Status: newassigned

by sswang, 14 years ago

Attachment: sub_sub_unique_fix.patch added

comment:4 by sswang, 14 years ago

Has patch: set

comment:5 by sswang, 14 years ago

still needs fix for unique_togethers

comment:6 by Łukasz Rekucki, 14 years ago

Severity: Normal
Type: Bug

comment:7 by Łukasz Rekucki, 13 years ago

Easy pickings: unset
Patch needs improvement: set
UI/UX: unset

comment:8 by aron45, 10 years ago

Owner: changed from sswang to aron45

comment:9 by aron45, 10 years ago

Resolution: fixed
Status: assignedclosed

comment:10 by Josh Smeaton, 10 years ago

Patch needs improvement: unset
Resolution: fixed
Status: closednew

I presume you didn't mean to close this case off, since you've linked a pull request.

comment:11 by Simon Charette, 10 years ago

Needs tests: set
Patch needs improvement: set
Version: 1.2master

comment:12 by aron45, 10 years ago

Cc: aron45 added

comment:13 by aron45, 10 years ago

I updated the pull request

comment:14 by Tim Graham, 10 years ago

Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:15 by Simon Charette <charette.s@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 79f27f2b61aeac763ae048416ef8a97c2b639ae8:

Fixed #15321 -- Honored ancestors unique checks.

Thanks to Tim for the review.

comment:16 by Simon Charette <charette.s@…>, 10 years ago

In fc49e736484892eaa516826d93660c7ab53a6c3e:

[1.8.x] Fixed #15321 -- Honored ancestors unique checks.

Thanks to Tim for the review.

Backport of 79f27f2b61aeac763ae048416ef8a97c2b639ae8 from master

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