Re: [Django] #31750: Abstract model field should not be equal across models

5 views
Skip to first unread message

Django

unread,
Jun 30, 2020, 4:13:04 AM6/30/20
to django-...@googlegroups.com
#31750: Abstract model field should not be equal across models
-------------------------------------+-------------------------------------
Reporter: Ryan Hiebert | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.0
(models, ORM) |
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 Carlton Gibson):

* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

OK, happy to look at a patch — assuming nothing breaks...

It'd be a change in behaviour, so would need calling out in the release
notes.

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

Django

unread,
Jun 30, 2020, 12:43:33 PM6/30/20
to django-...@googlegroups.com
#31750: Abstract model field should not be equal across models
-------------------------------------+-------------------------------------
Reporter: Ryan Hiebert | Owner: Ryan
| Hiebert
Type: Bug | Status: assigned

Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ryan Hiebert):

* cc: Ryan Hiebert (added)
* owner: nobody => Ryan Hiebert
* has_patch: 0 => 1
* status: new => assigned


Comment:

[https://github.com/django/django/pull/13124 PR]

Should this get backported? It feels like an (admittedly esoteric) bug fix
to me. It affects ordering, though I've minimized that effect to only
places where the ordering is currently undefined, as they are currently
considered equal.

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

Django

unread,
Jul 13, 2021, 2:44:32 AM7/13/21
to django-...@googlegroups.com
#31750: Abstract model field should not be equal across models
-------------------------------------+-------------------------------------
Reporter: Ryan Hiebert | Owner: Ryan
| Hiebert
Type: Bug | Status: closed

Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Nicolas Delaby):

Hi, I wonder if the submitted fix didn't introduce a subtle regression.
Given the example posted in the description, how would you evaluate the
following statements ?

**before**
https://github.com/django/django/commit/502e75f9ed5476ffe8229109acf0c23999d4b533
{{{#!python
assert B._meta.get_field('myfield') == C._meta.get_field('myfield')
assert B._meta.get_field('myfield') == A._meta.get_field('myfield')
assert C._meta.get_field('myfield') == A._meta.get_field('myfield')
}}}

**after**
https://github.com/django/django/commit/502e75f9ed5476ffe8229109acf0c23999d4b533
{{{#!python
assert B._meta.get_field('myfield') != C._meta.get_field('myfield')
assert B._meta.get_field('myfield') != A._meta.get_field('myfield')
assert C._meta.get_field('myfield') != A._meta.get_field('myfield')
}}}

What if it shouldn't be this ? Since B (or C) doesn't override
''myfield'', I would expect the subclass to evaluate equality as if the
field was defined on itself (given the parent model is abstract)
**maybe?**
{{{#!python
assert B._meta.get_field('myfield') != C._meta.get_field('myfield')
assert B._meta.get_field('myfield') == A._meta.get_field('myfield')
assert C._meta.get_field('myfield') == A._meta.get_field('myfield')
}}}

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

Django

unread,
Jul 13, 2021, 3:10:33 AM7/13/21
to django-...@googlegroups.com
#31750: Abstract model field should not be equal across models
-------------------------------------+-------------------------------------
Reporter: Ryan Hiebert | Owner: Ryan
| Hiebert
Type: Bug | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

> Hi, I wonder if the submitted fix didn't introduce a subtle regression.

This is an expected change IMO. Model fields don't make much sense without
models (even abstract) so we should distinguish between fields in abstract
models and the same fields inherited from them.

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

Django

unread,
Jul 13, 2021, 7:24:32 AM7/13/21
to django-...@googlegroups.com
#31750: Abstract model field should not be equal across models
-------------------------------------+-------------------------------------
Reporter: Ryan Hiebert | Owner: Ryan
| Hiebert
Type: Bug | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Nicolas Delaby):

Thanks for clarifying Mariusz.

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

Reply all
Reply to author
Forward
0 new messages