#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)
Change History (18)
comment:1 by , 15 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
by , 15 years ago
| Attachment: | sub_sub_unique_fix added |
|---|
comment:2 by , 15 years ago
| Owner: | changed from to |
|---|
comment:3 by , 15 years ago
| Status: | new → assigned |
|---|
by , 15 years ago
| Attachment: | sub_sub_unique_fix.patch added |
|---|
comment:4 by , 15 years ago
| Has patch: | set |
|---|
comment:6 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:7 by , 14 years ago
| Easy pickings: | unset |
|---|---|
| Patch needs improvement: | set |
| UI/UX: | unset |
comment:8 by , 11 years ago
| Owner: | changed from to |
|---|
opened pull request https://github.com/django/django/pull/3968
comment:9 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:10 by , 11 years ago
| Patch needs improvement: | unset |
|---|---|
| Resolution: | fixed |
| Status: | closed → new |
I presume you didn't mean to close this case off, since you've linked a pull request.
comment:11 by , 11 years ago
| Needs tests: | set |
|---|---|
| Patch needs improvement: | set |
| Version: | 1.2 → master |
comment:12 by , 11 years ago
| Cc: | added |
|---|
comment:14 by , 11 years ago
| Needs tests: | unset |
|---|---|
| Patch needs improvement: | unset |
| Triage Stage: | Accepted → Ready for checkin |
comment:15 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
fix for sub sub inheritance uniqueness