[Django] #20314: provide a management command to database views to cover inheritance

2 views
Skip to first unread message

Django

unread,
Apr 24, 2013, 8:53:47 AM4/24/13
to django-...@googlegroups.com
#20314: provide a management command to database views to cover inheritance
----------------------------------------------+--------------------
Reporter: chris@… | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
if you use inheritance like this:

{{{
class Foo(models.Model):
a = models.CharField(max_length=10)

class Bar(Foo):
b = models.CharField(max_length=10)
}}}

That will lead to two tables being created:

{{{
create table myapp_foo(id int, a varchar(10));
create table myapp_bar(foo_id, b varchar(10));
}}}

That's great. But when I need to run queries directly against the
database, I have to write all the joins myself. Since I'm
(extraordinarily) lazy, I would love to see a new management command that
creates a view like this:

{{{
create view bar_view as -- i hate that name, but it's good for an example
select * -- if I did this for real, I would enumerate the
columns
from myapp_foo
join myapp_bar on myapp_foo.id = myapp_bar.foo_id
}}}

for this trivial example, the typing isn't that much. But when you get
deep inheritance hierachies, the typing becomes a pain (especially since
the name of the "id" key keeps changing at each level).

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

Django

unread,
May 23, 2013, 7:38:04 AM5/23/13
to django-...@googlegroups.com
#20314: provide a management command to database views to cover inheritance
-------------------------------------+-------------------------------------
Reporter: chris@… | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 1.5
(models, ORM) | Resolution: wontfix
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0


Comment:

I can see what you're asking for here, and I can see the value, but Django
doesn't currently have *any* support for views, so this seems a little
premature.

In the meantime, you don't have to create the joins -- Django's ORM will
create the joins for you.

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

Reply all
Reply to author
Forward
0 new messages