Composite primary key & association entities as keys improvements#1113
Composite primary key & association entities as keys improvements#1113goetas wants to merge 13 commits into
Conversation
|
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DDC-3258 We use Jira to track the state of pull requests and the versions they got |
|
@goetas can you add a functional test that shows how this API is supposed to work at repository or collection level? |
|
@stof Thanks for reviewing my code |
|
It would be nice to have: //Admin1 is an entity with a composite key (country+code)
//Admin1AlternativeNames is an entity with a simple key (id) + Admin1 as association
$compositeEntity = $em->getRepository('Admin1')
->findOneBy(array('country' => 'IT', 'id' => 1));
$dql = $em->getRepository('Admin1AlternativeNames')
->createQueryBuilder('n')
->andWhere("n.admin1 = :admin1")
->setParameter("admin1", $compositeEntity);but at the moment seems to be complicated for me... :-( |
|
I think that postgres failure is not related to my changes... |
|
@goetas no I think this is related to the recent merge of doctrine/dbal#444 |
|
@goetas there's no BC break, since we do not allow custom persisters (yet) |
|
@guilhermeblanco good to know! |
There was a problem hiding this comment.
white line.. i will fix it :-(
|
Hi everybody! Now it should be complete! |
There was a problem hiding this comment.
Why not use ! empty($assoc['id']) instead of isset($assoc['id']) && $assoc['id']?
There was a problem hiding this comment.
Nice to know! I will do that!
There was a problem hiding this comment.
I would document it as integer[] which explains what type is inside the array too
There was a problem hiding this comment.
getTypes will return strings and integers... integers will be only when $value is an array
|
News on this? |
|
@Ocramius I can try to adapt it, but the current implementation of
|
This is something that I discussed in the PR that introduced it ( #1143 ): needs improvement
Making it recursive seems acceptable to me here: what's the problem with that? We could also make the entity identifiers accessible to it.
Should be improved also in the
It was just introduced, so it is obviously not yet used across the system :-)
Can you clarify on this? What would be a failure case? |
There was a problem hiding this comment.
I'm really not proud of this. Ideas?
There was a problem hiding this comment.
@Ocramius It was my mistake... fixed with goetas@268426a
/cc @FabioBatSilva
|
Ok, now looks better |
There was a problem hiding this comment.
@goetas this is very naive, and assumes a single column identifier.
What if I try to fetch the version of an entity with a composite identity?
There was a problem hiding this comment.
We may also avoid calling this method with a mixed $id, and change its signature to enforce array
There was a problem hiding this comment.
Changing the assignDefaultVersionValue signature, simplified a lot! Good advice! :-D
|
Now I'm more satisfied with the pull request status! |
|
Manually merged after a rebase at f908974 |
|
Thanks @goetas, as usual nice work :-) |
Hi!
I tried to implement the matching of entities that uses composite primary keys...
Any suggestion?
BC changes here https://github.com/doctrine/doctrine2/pull/1113/files#diff-c18001a2ca9928743b1e99854ffad33bL1611 (protected method makred as private and changed return type..)