Could you change it to this?
TableAQuery::create()
->useTableBQuery('a')
// some filters methods
->endUse()
->useTableBQuery('b')
// some filters methods
->endUse()
//->select(array('a.value_1', 'b.value_2'))
->addAsColumn('a.value_1', 'a.value_1')
->addAsColumn('b.value_2', 'b.value_2')
->find();
Caveat: I'm not a Propel user. I'm just wondering if the auto-generated useXXXQuery()
is setting the table alias on the same relation both times, or something like that.
As in the query above, replace your select()
with the two addAsColumn()
statements. It's a bit of a hack, but I think it achieves your desired result.
I just spent a while reading the Propel source code, and I've concluded that Propel 1 is not built to use different aliases on the same table joined multiple times, as you attempt. In ModelCriteria.php
, the use of $column->getFullyQualifiedName
ensures that the full name (table.column) is used in the select for joined tables, regardless of alias. (See https://github.com/propelorm/Propel/blob/7ddb0956b699343d33ce0c94043fa5970cc719c1/runtime/lib/query/ModelCriteria.php#L2082.) I expect this is indeed a bug.
If the addAsColumn()
method is used instead of select()
, Propel will use your literal SQL expression, whether it's an alias and column or anything else. That said, I'm not sure that's its intended use.