doctrine1 icon indicating copy to clipboard operation
doctrine1 copied to clipboard

getLimitSubquery fails if multiple tables are in FROM Clause

Open Amonadidis opened this issue 4 years ago • 2 comments

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.

Amonadidis avatar May 13 '20 20:05 Amonadidis

@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.

iricketson avatar Aug 31 '20 15:08 iricketson

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).

alquerci avatar Sep 01 '20 07:09 alquerci