FriendsOfSymfony1 / doctrine1

[DEPRECATED -- Use Doctrine2 instead] Doctrine 1 Object Relational Mapper.
http://www.doctrine-project.org
GNU Lesser General Public License v2.1
40 stars 75 forks source link

getLimitSubquery fails if multiple tables are in FROM Clause #78

Open Amonadidis opened 4 years ago

Amonadidis commented 4 years ago

For example a query with self join syntax SELECT * FROM example a, example b defined in DQL $query = ExampleTable::createInstance()->createQuery('a')->addFrom('example b'); is ignored by getLimitSubquery from Doctrine_Query in Query.php:1495. Commas are missing between the tables because getLimitSubquery just concats all parts from the FROM clause with a space character. The generated Query fails: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax.

iricketson commented 4 years ago

@Amonadidis Your best bet will be to extend your own query class (i.e. My_Query) and override the getLimitSubquery method. This way you can control behavior on a one-off basis if necessary.

alquerci commented 4 years ago

Hello @Amonadidis,

Firstly thank you for raise this issue.

In order to be explicit, the way to reproduce this bug it to execute this following statement?

ExampleTable::createInstance()
    ->createQuery('a')
    ->addFrom('example b')
    ->execute()
;

Hum, I suppose that it miss something.

Can you confirm or complete the full case, in order to reproduce the issue easily ?


Anyway, did you find a way to reach the same result by converting the second from to a join ? (I guess no, but it cost nothing to ask/suggest).