I am trying to use the ORM to build the following query:
"""SELECT * FROM category AS node, category AS parent WHERE node.lft BETWEEN
parent.lft AND parent.rgt"""

I am attempting to create the table aliases using .extra() but I'm having a
bit of difficulty.  I have left out the where statements in order to reduce
complexity while troubleshooting this issue.  My current code looks like
this.
category_list = Category.objects.all().extra(tables=['category'])

The way I understand the documentation [1] is if a table is listed in the
tables argument that already exists in the query, it will add the table with
a generic alias. However, it is simply ignoring the additional table.  This
is the SQL that is produces.

('SELECT "category"."id", "category"."lft", "category"."rgt",
"category"."tree_id", "category"."depth", "category"."name" FROM "category"
ORDER BY "category"."name" ASC', ())

Is this not the correct way to go about adding a table alias?  Am I just
missing something or am I way off track here?




[1]
http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to