mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-2891: Impossible to pass a limit to a subquery #3606
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jan 7, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user johnconnor:
It seems that passing the limit to a subquery is not working
The query works but the is no specified limit in the resulting SQL.
I am aware that DQL does not support the limits and offsets, so i guess there should be another way to get this working?
@doctrinebot commented on GitHub (Jan 8, 2014):
Comment created by @deeky666:
Can you please tell which database platform you are using? Because limiting results heavily depends on the platform used.
@doctrinebot commented on GitHub (Jan 8, 2014):
Comment created by johnconnor:
MySql
@doctrinebot commented on GitHub (Jan 8, 2014):
Comment created by @deeky666:
Hmmm I am not quite sure if the limit/offset is invoked for subqueries but I don't see why it shouldn't. Also I think this is not a DBAL issue because the limit/offset support for MySQL is the easiest we have on all platform. See: https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L51-L63
The query doesn't have to be modified but instead only the limit clause is appended to the query. Can you maybe provide the generated SQL for that query?
@doctrinebot commented on GitHub (Jan 8, 2014):
Comment created by johnconnor:
I think if you try to build any query with QueryBuilder, set a limit to it with setMaxResults then call getDQL method, you should see that the output contains no info about limit.
So if you look at my code example , at $qb->expr()->in('p.id', $subquery->getDQL()), then you will see that the getDQL passes to the IN expression a query which already DOES NOT have limit. So this is the place where any info about limits and offsets gets lost.
So I fail to see what it has to do with any specific db engine,however I can provide the mysql resulting query if you want,though it looked perfectly normal to me,just lacks the LIMIT part.
@cesardmoro commented on GitHub (Mar 28, 2017):
You any news on this ? please maybe a hack ?
@vladimmi commented on GitHub (Jun 15, 2018):
Just to note - it's still impossible to use subqueries with limits.
@adrienpayen commented on GitHub (Aug 22, 2021):
New note 3 years later, it is still impossible to use subqueries with limits. Any workaround ?
@greg0ire commented on GitHub (Aug 22, 2021):
@adrienpayen @vladimmi if I had a contribution graph like yours, I would refrain from complaining about a lack of contributions. You've done nothing to fix an issue that directly impacts you, so why would you expect people that are not impacted to do the work for you? Please stop the spamming and start being constructive.
You could provide a failing test case, or use a debugger to pinpoint where the issue is.
@vladimmi commented on GitHub (Aug 23, 2021):
@greg0ire If I was such a tender snowflake, I would refrain from using public services having comments - especially bug trackers. And especially I would at least read ticket before posting anything there - because "failing case" was provided 7 years ago in the very first message and "pinpointed where the issue is" in the same day several messages later.
@greg0ire commented on GitHub (Aug 23, 2021):
Well then you can move on to the next step: fix it!
If I had to read every thread when people ask for news, I wouldn't be able to make any progress. That being said, the first comment is not really what I meant by failing test case. You can still work on that before attempting to fixing the bug. Make a PR with the code snippet above in a PHPUnit test.
Hmmmm… I think the discussion is too heated, don't you agree?