#21338: Can't use the same class name for proxy models
-------------------------------------+-------------------------------------
     Reporter:  srenskiy@…           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.4
  (models, ORM)                      |               Resolution:  needsinfo
     Severity:  Normal               |             Triage Stage:
     Keywords:  model                |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by shai):

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


Comment:

 By 'x' in x.A I mean a module -- if you want two models with the same name
 in the same module, I think we would flat out reject it.

 Models in the same app having the same name only makes partial sense if
 they are in separate modules -- that is, your app `app` has some models
 defined in `app.x` and some in `app.y` (or, more likely, `app.models.x`
 and `app.models.y`).

 What I meant was not about "lost proxy models", but simply that you claim
 in the patch that, for model creation, when you pick up model `A` from app
 `app`, it doesn't matter if you pick the concrete model or the proxy. Even
 in the way you intended, that is not generally true (e.g. the proxy may
 use more stringent validations, and cause instance creation to fail when
 the parameters are valid for the concrete model). But my point was that
 nothing guarantees that the proxy model is indeed a proxy for the concrete
 model with the same name -- it can be a proxy for a completely unrelated
 model. Think about concrete classes `tools.Tool` and `drinks.ScrewDriver`,
 and proxy class `tools.ScrewDriver`.

 Nothing prevents you from having `app_store.Receipt` and
 `google_play.Receipt`; I just don't see why these two need to be in the
 same app.

 Finally, the Liskov principle is not symmetric, and definitely makes no
 mention of naming your subclasses the same as superclasses.

 In short -- I'm entirely unconviced. Closing as needsinfo -- feel free to
 re-open if you have a more compelling argument.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21338#comment:5>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/076.8d6bef342c46991565afc6af87b16edb%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to