Wednesday, June 30, 2010

expressions in values()

Hi,

I have the following query:

AnalyzedFile.objects.filter(bug_signature__bug_condition__tracked_change=cr).values("scm__path")

In other words, the result is a list of AnalizedFile.scm.path values.
I'd like to change the query so that the returned value is a
combination of two fields: scm.path + "#" + scm.revision. So far I
haven't been able to figure out how to do this. I've looked at using
extra():

AnalyzedFile.objects.filter(bug_signature__bug_condition__tracked_change=cr).extra(select={'path':"..."})

The problem with this approach is that I don't know how to refer to
the fields of the table representing the "scm" relationship. Since
that table is part of a join and Django auto-generates table aliases,
I wouldn't now what to prefix the column names with.

Any thoughts?

BTW, this query is later used inside of another query (resulting in a
nested select), so I need to do the path/revision concatenation in
SQL. Otherwise, I would've done it easily in python.

Thanks
Dmitry

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

No comments:

Post a Comment