#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.aafe022b908535da99bcfae2427e461e%40djangoproject.com.

Reply via email to