Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert function failing for Mongo ODM EmbedMany tag #84

Open
eastern-ravindra opened this issue May 13, 2024 · 2 comments
Open

Assert function failing for Mongo ODM EmbedMany tag #84

eastern-ravindra opened this issue May 13, 2024 · 2 comments

Comments

@eastern-ravindra
Copy link

eastern-ravindra commented May 13, 2024

https://github.com/doctrine/doctrine-laminas-hydrator/blame/81ee8121f42dcc0b6f39e08dce56b10baf6fb95f/src/DoctrineObject.php#L355

if ($metadata->hasAssociation($field)) {
                $target = $metadata->getAssociationTargetClass($field);
                assert($target !== null);

Above assert code is failing for mongoDB, when we are using EmbedMany argument without target document locally.

According to documentation, EmbedMany without target document is allowed to embed different documents in same field.(https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/2.7/reference/embedded-mapping.html#mixing-document-types)

Does this assert check is really needed as null value is also accepted for mongodb?

@TomHAnderson
Copy link
Member

If you take out the assertion, does it work? There is this line too that expects the target:

$this->toMany($object, $field, $target, $value);

@eastern-ravindra
Copy link
Author

eastern-ravindra commented May 14, 2024

If you take out the assertion, does it work? There is this line too that expects the target:

$this->toMany($object, $field, $target, $value);

toMany function is not working in this case, giving

Doctrine\Persistence\Mapping\MappingExceptionClass '' does not exist

I think, we need to override this function where we can add conditions if $target is null

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

No branches or pull requests

2 participants