Unique constraint (from DoctrineMongoDBBundle) doesn't work with embedded document #295

Open
pierrre opened this Issue Apr 26, 2012 · 9 comments

5 participants

@pierrre

I'm trying to use the "unique validator" from the DoctrineMongoDBBundle, but I get this error:
[BadMethodCallException] Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo::getAssociationTargetClass($assocName) is not implemented yet.

Am I doing something wrong?

I use Symfony 2.1, and latest bundles/projects versions.

@pierrre

I have more details on this problem:

  • "unique" constraint works with a "normal" document
  • "unique" constraint doesn't work with an embedded document
@jmikola
Doctrine member

Cross-linking: doctrine/DoctrineMongoDBBundle#97

The validator itself looks fine. We likely just need to implement this method (and others if possible) to support the use case.

@jmikola jmikola referenced this issue in doctrine/DoctrineMongoDBBundle Apr 27, 2012
Closed

UniqueValidator is invalid with master #77

@pierrre

I have a small question: does it make sense to have an "unique" constraint on an embedded document?

@jmikola
Doctrine member

I think it's possible to define a unique index on an embedded document, which should get picked up when the concrete document (corresponding to a collection) determines its indexes. In that sense, I think it's reasonable for embedded documents to also define unique constraints for those fields.

@jmikola jmikola was assigned May 18, 2012
@pierrre

The real problem is: we can't use the "unique" constraint on a field with an "association" (reference or embed).
Do you think it's easy to implement?

@peshi

@jwage ping
I'm asking the same questions, will this get looked at soon?
#97

@malarzm malarzm added the needs test label Jan 21, 2016
@davidloubere

Issue looks still relevant early 2016.
Can we have a status please?

@malarzm
Doctrine member

@davidloubere: as denoted by label status is "needs test" - please feel free to create a failing unit test and submit is a PR, this will speed up working on the issue

@malarzm
Doctrine member

According to my tests from #1363 DocumentRepository::findBy() already accepted embedded documents and was working properly - call for tests is still open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment