You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Symfony version used: 4.4.18 doctrine/mongodb-odm version used: 2.1.2 doctrine/mongodb-odm-bundle version used : 4.2.2
Description
When we use the UniqueEntity validator of Symfony by the Unique constraint of the doctrine bundle with a repository method that return an Iterator (in my case an instance of Doctrine\ODM\MongoDB\Iterator\CachingIterator which implement \Iterator interface), Symfony does not use correctly the iterator.
An empty result arrive to this line. The current() method return false instead of null so we end up with the result [false] and the error message is created.
I tested the use case on a old version of Symfony (3.3) and doctrine (1.2.9 for the ODM and 3.5.3 for the bundle), Doctrine return a instance of Doctrine\ODM\MongoDB\Cursor class wich return null on the method current()
How to reproduce
Add an Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique constraint with a repository method that return an Iterator (for example with the execute() method of the QueryBuilder) and use the validator with an empty result.
Possible Solution
Check also if the Iterator is valid like this :
Symfony version used: 4.4.18
doctrine/mongodb-odm version used: 2.1.2
doctrine/mongodb-odm-bundle version used : 4.2.2
Description
When we use the UniqueEntity validator of Symfony by the Unique constraint of the doctrine bundle with a repository method that return an Iterator (in my case an instance of
Doctrine\ODM\MongoDB\Iterator\CachingIterator
which implement\Iterator
interface), Symfony does not use correctly the iterator.An empty result arrive to this line. The
current()
method return false instead of null so we end up with the result[false]
and the error message is created.I tested the use case on a old version of Symfony (3.3) and doctrine (1.2.9 for the ODM and 3.5.3 for the bundle), Doctrine return a instance of
Doctrine\ODM\MongoDB\Cursor
class wich return null on the methodcurrent()
How to reproduce
Add an
Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique
constraint with a repository method that return an Iterator (for example with theexecute()
method of the QueryBuilder) and use the validator with an empty result.Possible Solution
Check also if the Iterator is valid like this :
The text was updated successfully, but these errors were encountered: