[Django] #16739: field clash not detected beyond parent

12 views
Skip to first unread message

Django

unread,
Aug 31, 2011, 7:51:39 PM8/31/11
to django-...@googlegroups.com
#16739: field clash not detected beyond parent
---------------------------+----------------------------------------------
Reporter: Leo | Owner: nobody
Type: Uncategorized | Status: new
Milestone: | Component: Database layer (models, ORM)
Version: SVN | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------+----------------------------------------------
When a local field in a class has the same name as a field in the
superclass Django throws a FieldError when it spins up. However, it only
checks the immediate parent, it doesn't go further up the tree so the
following code doesn't trigger a FieldError (which it should):

{{{
class A(models.Model):
foo = models.IntegerField()

class B(A):
pass

class C(B):
foo = models.IntegerField()
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/16739>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 4, 2011, 4:53:35 PM9/4/11
to django-...@googlegroups.com
#16739: field clash not detected beyond parent
-------------------------------------+-------------------------------------
Reporter: Leo | Owner: nobody
Type: | Status: new
Uncategorized | Component: Database layer
Milestone: | (models, ORM)
Version: SVN | Severity: Normal
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0


Comment:

I confirm the bug. With this code in a `models.py`:
{{{
class GrandParent(models.Model):
number = models.IntegerField()

class Parent(GrandParent):
pass

class Child(Parent):
number = models.IntegerField()
}}}

Expected result of `./manage.py validate`:
{{{
FieldError: Local field 'number' in class 'Child' clashes with field of
similar name from base class 'GrandParent'
}}}

Actual result: no error.

I tried to write a test case in `invalid_models`, but that didn't work
because the name clash creates an exception, not a validation error.

--
Ticket URL: <https://code.djangoproject.com/ticket/16739#comment:1>

Django

unread,
Sep 6, 2012, 8:52:25 PM9/6/12
to django-...@googlegroups.com
#16739: field clash not detected beyond parent
-------------------------------------+-------------------------------------
Reporter: Leo | Owner: swcisel
Type: Uncategorized | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by swcisel):

* owner: nobody => swcisel
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/16739#comment:2>

Django

unread,
Feb 22, 2013, 2:16:23 PM2/22/13
to django-...@googlegroups.com
#16739: field clash not detected beyond parent
-------------------------------------+-------------------------------------
Reporter: Leo | Owner: swcisel
Type: Bug | Status: assigned

Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by akaariai):

* type: Uncategorized => Bug


--
Ticket URL: <https://code.djangoproject.com/ticket/16739#comment:3>

Django

unread,
Dec 12, 2014, 2:17:15 PM12/12/14
to django-...@googlegroups.com
#16739: Model field clash not detected beyond parent
--------------------------------------+------------------------------------
Reporter: Leo | Owner:
Type: Bug | Status: new
Component: Core (System checks) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* owner: swcisel =>
* status: assigned => new
* component: Database layer (models, ORM) => Core (System checks)


Comment:

Confirmed this is still an issue with the attached test for Django's test
suite.

--
Ticket URL: <https://code.djangoproject.com/ticket/16739#comment:4>

Django

unread,
Mar 22, 2015, 2:08:16 PM3/22/15
to django-...@googlegroups.com
#16739: Model field clash not detected beyond parent
--------------------------------------+------------------------------------
Reporter: Leo | Owner:
Type: Bug | Status: new
Component: Core (System checks) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by karlwnw):

I think this ticket can be marked as fixed or duplicate now, fixed here
#24249.

--
Ticket URL: <https://code.djangoproject.com/ticket/16739#comment:5>

Django

unread,
Mar 22, 2015, 2:55:13 PM3/22/15
to django-...@googlegroups.com
#16739: Model field clash not detected beyond parent
-------------------------------------+-------------------------------------
Reporter: Leo | Owner:
Type: Bug | Status: closed
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* resolution: => duplicate


Comment:

Right, thanks for checking (Tim's test is now passing well).

--
Ticket URL: <https://code.djangoproject.com/ticket/16739#comment:6>

Django

unread,
Mar 22, 2015, 5:59:20 PM3/22/15
to django-...@googlegroups.com
#16739: Model field clash not detected beyond parent
-------------------------------------+-------------------------------------
Reporter: Leo | Owner:
Type: Bug | Status: closed
Component: Core (System | Version: master
checks) |
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Leo):

Thanks guys! Great to have this cleaned up!

--
Ticket URL: <https://code.djangoproject.com/ticket/16739#comment:7>

Reply all
Reply to author
Forward
0 new messages