propelorm/Propel — pull request #374 by fabeat (2012-06-04 13:55:13+00:00)
Title: Joins on self referring classes

Hi,

I've found a bug where joins on self referring classes do not work correctly using queries. The generated SQL is wrong.

Here a snippet from the test output:

```
$ phpunit test/testsuite/misc/SelfReferringTest

[...]

.E.E

Time: 0 seconds, Memory: 8.25Mb

There were 2 errors:

1) SelfReferringTest::testBasicQueryWithLeftJoin
PropelException: Unable to execute SELECT statement [SELECT self_referring.ID, self_referring.RELATED_ID, self_referring.NAME FROM LEFT JOIN `self_referring` ON (self_referring.RELATED_ID=self_referring.ID) WHERE Name LIMIT 1] [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN `self_referring` ON (self_referring.RELATED_ID=self_referring.ID) WHER' at line 1]

[...]

2) SelfReferringTest::testBasicQueryWithNamedLeftJoinAndInlusionOfRelatedObject
PropelException: Unable to execute SELECT statement [SELECT self_referring.ID, self_referring.RELATED_ID, self_referring.NAME, self_referring.ID, self_referring.RELATED_ID, self_referring.NAME FROM LEFT JOIN `self_referring` ON (self_referring.RELATED_ID=self_referring.ID) WHERE self_referring.NAME=:p1 LIMIT 1] [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN `self_referring` ON (self_referring.RELATED_ID=self_referring.ID) WHER' at line 1]

[...]

FAILURES!
Tests: 4, Assertions: 0, Errors: 2.
```