Comment 4 for bug 500163

Revision history for this message
Anatoly Kupriyanov (kan-izh) wrote :

This is small patch which does what I want. It adds a function "dir()" which creates a new Q-object with initialised direct paths.
So now it's possible to use it like this:
QEntity.entity.link1.dir().link2.dir().link3.id.eq(42)
And all types are checked at compile-time.

There is more neat solution - to change public fields to methods, so link1 will be not a field, but a methods, which creates a new Q-object with initialized direct paths.
QEntity.entity.link1().link2().link3().id.eq(42)
But it's not easy to change now, not breaking an existing code. Or as alternative create both - and methods, and fields...

Join aliases which you mentioned is not very neat solution - first of all it requires to declare a local variable, and moreover - it doesn't work for subqueries.

BTW, is there any explanation why sub-queries don't support joins?

Merry Christmas! :)