Open
Description
Bug Report
This code works on v1.x. But fails in V2.
I've got an aggregation query, in last stage I've got a $project like this:
$builder
->addFields()
->field('purchase')
->expression('$$ROOT');
I'm using a Hydraration Class like this:
<?php
/**
* @ODM\QueryResultDocument
*/
class PurcahseQuery
{
/**
* @var Purchase
* @ODM\EmbedOne(targetDocument="App\Document\Purchase")
*/
protected $purchase;
/**
* @return Purchase
*/
public function getPurchase(): Purchase
{
return $this->purchase;
}
}
This triggers an array to string conversion on CachingIterator.php line 128:
$key = $this->iterator->key();
If I change project step to this:
$builder
->addFields()
->field('purchase')
->expression('$_id');
And my hydratation class to this:
<?php
/**
* @ODM\QueryResultDocument
*/
class PurcahseQuery
{
/**
* @var Purchase
* @ODM\ReferenceOne(targetDocument="App\Document\Purchase", storeAs="id")
*/
protected $purchase;
It works ok, putting purchase data into $purchase and triggers no array to string conversion error.
Q | A |
---|---|
BC Break | no |
Version | 2.0-RC1 |