mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2988: Notice: Undefined index: joinColumns in BasicEntityPersister.php #3716
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Feb 19, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user dvaeversted:
When trying to use findBy on a ManyToMany field i receive the error:
Notice: Undefined index: joinColumns in lib/Doctrine/ORM/Persisters/BasicEntityPersister.php
It seems to be caused internally by the code expecting 'joinColumns' to be directly on the association, however it is found under 'joinTable'.
I have attached a patch that atleast fixes my case, hopefully it can be used to pin-point what the error is.
@doctrinebot commented on GitHub (Feb 19, 2014):
@doctrinebot commented on GitHub (Feb 19, 2014):
Comment created by dvaeversted:
Might be related to this one: http://www.doctrine-project.org/jira/browse/DDC-2808
@doctrinebot commented on GitHub (May 28, 2014):
Comment created by litz:
Doctrine ORM 2.4.2 Here.
Here are my annotations
https://gist.github.com/LitzOuille/3cf2e73e169c032147ea
The thing I'm trying to do is
$questionRepository->findBy(array('contacts' => $ids)); // $ids = array(1,2,3, ...)
@doctrinebot commented on GitHub (May 30, 2014):
Comment created by @ocramius:
[~calinpristavu] did you validate your mappings?
@doctrinebot commented on GitHub (May 30, 2014):
Comment created by calinpristavu:
I failed, sorry.
The error came from the many-to-many condition in the entity.
Sorry for generating confusion, comment deleted !
The many-to-one works just fine !
@doctrinebot commented on GitHub (Jun 3, 2014):
Comment created by litz:
A little feedback? Is this a bug? Can it be fixed?
Thanks
@doctrinebot commented on GitHub (Jun 3, 2014):
Comment created by @ocramius:
[litz] that particular repository call cannot work. How are we supposed to find an entity from a list of associated IDs? It would have to be the exact match...
Assuming that API would work as I envision it, it looks like a missing feature.
[dvaeversted] in order to accept a patch, we first need a failing test case demonstrating the failing scenario.
@doctrinebot commented on GitHub (Jun 3, 2014):
Comment created by litz:
EDIT: Ok my bad.
I am using findBy(array('id', $arrayIds)) and it is working. I thought I was using on a ManyToOne relationship, but no.
EDIT2: @ocramius In fact I would like to find all questions for which the contacts' list contains at least one id. Something like
SELECT q.*
FROM Question q, QuestionContact qc //qc = jointable
WHERE q.id = qc.question_id
AND qc.contact_id IN ($ids)
EDIT3: Actually when I try to findBy('ManyToMany', $id), it does not work either. I think I will have to use a repository for every query using a ManyToMany relationship.
EDIT4: Ok, so, as said in the original post, findBy does not work with many-to-many.
Notice: Undefined index: joinColumns (BasicEntityPersister.php line 1666)
Dump($this->class->associationMappings[$field]): https://gist.github.com/LitzOuille/51929fdc3eda5576ed31
@doctrinebot commented on GitHub (Jun 13, 2014):
Comment created by Eversor:
I've got the same issue, also running doctrine 2.4.2:
multiple users can have multiple departments:
Then I want to find all the users that are within the departments that the current user has:
This results in this error:
{quote}
Notice: Undefined index: joinColumns in .../vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1665
{quote}
@doctrinebot commented on GitHub (Jan 29, 2015):
Comment created by Scooty:
I have same problem with doctrine 2.4.7:
Notice: Undefined index: joinColumns in vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php at line 1670
@doctrinebot commented on GitHub (Feb 6, 2015):
Comment created by geoB:
What is meant by "Awaiting feedback"?
After encountering the same error as described above I've created a new Symfony project with the sole purpose of reproducing the error. If this would be of use in resolving the issue please let me know. I can make the code available in whatever form would be the most useful.
@doctrinebot commented on GitHub (Feb 6, 2015):
Comment created by @ocramius:
{quote}in order to accept a patch, we first need a failing test case demonstrating the failing scenario.{quote}
We don't need a symfony project or an example app: we have our own test suite that can be found at https://github.com/doctrine/doctrine2/tree/master/tests
@doctrinebot commented on GitHub (Feb 13, 2015):
Comment created by cboisvert:
I have the same issue. Want to filter on a relationship on the owning side (Because I got an error on the non owning side saying I needed to be on the owning side) and I get the exact same error.
@doctrinebot commented on GitHub (Feb 19, 2015):
Comment created by aivus:
As workaround we can collect IDs and pass it to queryBuilder, like:
@doctrinebot commented on GitHub (Feb 19, 2015):
Comment created by @ocramius:
Don't code workarounds: provide a test case, so that a patch can be created ;-)
@doctrinebot commented on GitHub (Feb 19, 2015):
Comment created by aivus:
I'll this ASAP.
@doctrinebot commented on GitHub (Feb 20, 2015):
Comment created by aivus:
Here is the test: https://github.com/doctrine/doctrine2/pull/1307
Here is the test log on travis-ci: https://travis-ci.org/aivus/doctrine2/builds/51516067
@doctrinebot commented on GitHub (Mar 16, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1307] was labeled:
https://github.com/doctrine/doctrine2/pull/1307
@doctrinebot commented on GitHub (May 26, 2015):
Comment created by aivus:
On master branch getting this error now:
for this test: https://github.com/doctrine/doctrine2/pull/1307
@TriAnMan commented on GitHub (Feb 8, 2016):
I also suffer from this bug.
@beberlei is the fix proposed by dvaeversted available anywhere?
@kirkbushell commented on GitHub (Mar 26, 2016):
I'm seeing this atm. Is this still an issue!?
@shakaran commented on GitHub (Oct 13, 2017):
This is still an issue to me in ^2.5 version.
I found the temporal workaround here:
https://stackoverflow.com/questions/10806881/one-to-one-self-referencing-bi-directional-relationship
In my case I have a entity Folder, that store an attribute called "parent", which self reference to the same entity folder in bidirectional.
So I solve like:
Also notice that $this->currentPersisterContext doesn't have any info in the $association array to index joinColumns even if you define the joinColumns for the LEFT JOIN. So it is totally failuring for self reference bidirectional:
@lcobucci commented on GitHub (Oct 29, 2017):
@shakaran could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing.
You can find examples on
388afb46d0/tests/Doctrine/Tests/ORM/Functional/Ticket@shakaran commented on GitHub (Oct 30, 2017):
@lcobucci not sure if the failing test could be used as YAML? There are some particular example which I could use as YAML loading example? I describe above the YAML needed and the stackoveflow question has another example too.
@Majkl578 commented on GitHub (Dec 9, 2017):
@shakaran Please map the failing test using annotations or XML only, YAML support is going to be removed in Doctrine 3.0. It's pretty straightforward to map entites using annotations, most of the tests in the folder linked above will serve as great examples.
@mpdude commented on GitHub (Jun 26, 2023):
A current version of the test against 2.15 is in #10801.
@mpdude commented on GitHub (Jun 26, 2023):
I guess it comes down to this question:
When you call
\Doctrine\ORM\EntityRepository::findBy()and pass a criteria like['groups' => [$group1, $group2]], what would we expect to happen whengroupsrefers to a many-to-many association?Find all users that have one of the given groups in their list of groups, or all of them?
Can we define it in a way that would be consistent with other association types?
@mpdude commented on GitHub (Jun 27, 2023):
The more I look at it, the more I believe that
EntityPersister::load()was never designed to support criteria aiming at for association fields, at least not collection-values ones. Maybe to-one collections work (by coindicence?) because the referred-to entity identifier is available as a plain value in the referring table.The fact that we have something that looks related to many-to-many handling in
\Doctrine\ORM\Persisters\Entity\BasicEntityPersister::getSelectConditionStatementColumnSQLcomes from #1249: It's used when when coming from a CollectionPersister to find the entities referred-to by that collection.@beberlei @guilhermeblanco if you agree then proably the best we can do about this is to reject such criteria with a meaningful exception message and update documentation to mention this as a limitation.