Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Support for Doctrine 2.5 #187

Closed
rande opened this issue Apr 18, 2015 · 15 comments · Fixed by #210
Closed

Support for Doctrine 2.5 #187

rande opened this issue Apr 18, 2015 · 15 comments · Fixed by #210

Comments

@rande
Copy link
Contributor

rande commented Apr 18, 2015

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
@stephpy
Copy link
Owner

stephpy commented Apr 20, 2015

Mmh, do you see an other way to define an order by in a Doctrine QueryBuilder ?

It seems pager does not work ...

@rande
Copy link
Contributor Author

rande commented Apr 24, 2015

@stephpy it is a possible regression in Doctrine. Can you provide a simple reproducible case to report to the Doctrine's team ?

@ppetermann
Copy link

did anything happen on this? like was it reported to doctrine? any link to that issue?

@mpclarkson
Copy link

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",

@jschroed91
Copy link

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

@OskarStark
Copy link

it is tagged now in 2.5.1 : https://github.com/doctrine/doctrine2/releases/tag/v2.5.1

@mpclarkson
Copy link

Argh... I literally just debugged this and rolled back to 2.4.3 again half an hour ago!

@greg0ire
Copy link

I'm trying to upgrade sonata-project.org, and am using 2.5.5, and still experience the bug reported by @rande

@core23
Copy link
Contributor

core23 commented Jan 11, 2017

Any news here?

@stephpy
Copy link
Owner

stephpy commented Jan 11, 2017

I didn't found time to fix it.
If you find a solution, a PR is welcome.

@schurtertom
Copy link

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?

@OskarStark
Copy link

the link was broken: sonata-project/SonataTimelineBundle#105

@schurtertom
Copy link

@OskarStark thank you!

@schurtertom
Copy link

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.

@core23
Copy link
Contributor

core23 commented Feb 3, 2018

Look like it is fixed in doctrine/orm 2.6.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants