doctrine / mongodb-odm

The Official PHP MongoDB ORM/ODM
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
MIT License
1.09k stars 504 forks source link

Compatibility with MongoDB 3.6 #1664

Closed metanav closed 6 years ago

metanav commented 7 years ago

Will doctrine/mongodb-odm 1.2 and doctrine/mongodb be compatible with the upcoming MongoDB 3.6?

alcaeus commented 7 years ago

We haven't added any of the new features yet and won't do so until ODM 2.0. As long as no BC breaks are present in MongoDB, ODM will work fine with MongoDB 3.6.

metanav commented 7 years ago

@alcaeus Thanks for letting me know the status. The new $lookup's "pipeline" is much needed option in my opinion. It would be nice to add it before ODM 2.0. Otherwise, how can I use that with the existing $lookup implementation in the doctrine/mongo?

alcaeus commented 7 years ago

@metanav With the release of 1.2 yesterday, you can use the existing $lookup pipeline stage in the aggregation builder without workarounds. 1.2 is the last feature release supporting ext-mongo, and we're now focussing on switching to ext-mongodb for ODM 2.0. Many of the new features in recent MongoDB versions won't work with the legacy driver anyways, so that's why we prioritized the driver switch.

metanav commented 7 years ago

I am able to use lookup with the latest release (1.2) . But my question was how to use "pipeline" within lookup (MongoDB 3.6 Join Conditions and Uncorrelated Sub-queries). Can I use expression to add unimplemented option in the existing implementation?

{
   $lookup:
     {
       from: <collection to join>,
       let: { <var_1>: <expression>, …, <var_n>: <expression> },
       pipeline: [ <pipeline to execute on the collection to join> ],
       as: <output array field>
     }
}
alcaeus commented 7 years ago

I haven't looked at any of the new features in detail. I thought about adding some 3.6 features for a moment but decided it's not worth pushing back 1.2 for. I'm aiming for a first beta of ODM 2.0 before the end of the year with a final release no later than Q1 2018.

Until then you can use the pipeline field, but you will not be able to specify it via the aggregation builder. Without knowing exactly what it does, I'd guess you have to xtract the built pipeline using getPipeline, inject the new pipeline (by calling getPipeline on what would most likely be a second aggregation builder instance) and then manually doing what Builder::execute does.

metanav commented 7 years ago

I guess we are adding nested pipeline in the existing $facet implementation. I was just thinking in that way. Anyway I will try the workaround you suggested for now.