Support for Doctrine 2.5
Closed this issue · 15 comments
The bundle breaks with the new Doctrine 2.5 release
The query generated by TimelineManager::getTimeline
fails with Doctrine 2.5 due to a wrong alias. From the following code, ORDER BY t0_.created_at_2 DESC
query should be inside the select:
$qb = $this->getBaseQueryBuilder($options['type'], $options['context'], $subject)
->select('t, a, ac, c')
->innerJoin('t.action', 'a')
->leftJoin('a.actionComponents', 'ac')
->leftJoin('ac.component', 'c')
->orderBy('t.createdAt', 'DESC')
;
But if you look to the generated query, it seems to be used outside the inner select.
SELECT DISTINCT id_3 FROM (
SELECT
t0_.context AS context_0, t0_.type AS type_1,
t0_.created_at AS created_at_2, t0_.id AS id_3,
t1_.verb AS verb_4, t1_.status_current AS status_current_5, t1_.status_wanted AS status_wanted_6,
t1_.duplicate_key AS duplicate_key_7, t1_.duplicate_priority AS duplicate_priority_8,
t1_.created_at AS created_at_9, t1_.id AS id_10,
t2_.type AS type_11, t2_.text AS text_12, t2_.id AS id_13,
t3_.model AS model_14, t3_.identifier AS identifier_15, t3_.hash AS hash_16, t3_.id AS id_17
FROM timeline__timeline t0_
INNER JOIN timeline__action t1_ ON t0_.action_id = t1_.id
LEFT JOIN timeline__action_component t2_ ON t1_.id = t2_.action_id
LEFT JOIN timeline__component t3_ ON t2_.component_id = t3_.id
WHERE
t0_.type = "timeline"
AND t0_.context = "SONATA_ADMIN"
AND t0_.subject_id = 1
) dctrn_result
ORDER BY t0_.created_at_2 DESC
LIMIT 25 OFFSET 0
Mmh, do you see an other way to define an order by in a Doctrine QueryBuilder ?
It seems pager does not work ...
@stephpy it is a possible regression in Doctrine. Can you provide a simple reproducible case to report to the Doctrine's team ?
did anything happen on this? like was it reported to doctrine? any link to that issue?
I've had a load of problems with doctrine 2.5 as it includes some BC breaks. I've hard coded my dependency as follows, which has solved all my issues:
"doctrine/dbal": "2.4.3 as 2.5",
Looks like there was a fix for this merged into doctrine's master branch (doctrine/orm#1377), but I'm still waiting for it to be merged into the 2.5 branch and tagged.
Here's the issue in JIRA: http://www.doctrine-project.org/jira/browse/DDC-3688
it is tagged now in 2.5.1
: https://github.com/doctrine/doctrine2/releases/tag/v2.5.1
Argh... I literally just debugged this and rolled back to 2.4.3 again half an hour ago!
I'm trying to upgrade sonata-project.org, and am using 2.5.5, and still experience the bug reported by @rande
Any news here?
I didn't found time to fix it.
If you find a solution, a PR is welcome.
composer.json
"doctrine/orm": "^2.5",
will give me this error:
https://github.com/sonata-project/SonataTimelineBundle/issues/105
if I use doctrine/orm v2.4.8 it is working, but not an option, since I have then other problems with other bundles.
Do you have any time to fix this bug?
the link was broken: sonata-project/SonataTimelineBundle#105
@OskarStark thank you!
I did some research and found a solution:
/vendor/stephpy/timeline-bundle/Driver/ORM/TimelineManager.php
Line 42
changed
->orderBy('t.createdAt', 'DESC')
to
->orderBy('t.id', 'DESC')
an other possibility would be adding createdAt to the t query.
Look like it is fixed in doctrine/orm 2.6.0