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

DDC-57: ManyToMany PDOException MySQL Syntax Error #5076

Closed
doctrinebot opened this issue Oct 22, 2009 · 13 comments
Closed

DDC-57: ManyToMany PDOException MySQL Syntax Error #5076

doctrinebot opened this issue Oct 22, 2009 · 13 comments
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user purnama:

For ManyToMany Relation I have an MySQL Sytax Error from the StandardEntityPersister.php

Hier is my error code:

2009-10-22T09:39:31+02:00 ERR (3): exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= lemma_type.type_id WHERE lemma_type.lemma_id = NULL' at line 1' in /usr/local/zend/apache2/htdocs/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php:475
Stack trace:
#0 /usr/local/zend/apache2/htdocs/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(475): PDOStatement->execute(Array)
#1 /usr/local/zend/apache2/htdocs/doctrine/lib/Doctrine/ORM/Mapping/ManyToManyMapping.php(186): Doctrine\ORM\Persisters\StandardEntityPersister->loadManyToManyCollection(Object(Doctrine\ORM\Mapping\ManyToManyMapping), Array, Object(Doctrine\ORM\PersistentCollection))
#2 /usr/local/zend/apache2/htdocs/doctrine/lib/Doctrine/ORM/PersistentCollection.php(233): Doctrine\ORM\Mapping\ManyToManyMapping->load(Object(kateglo\application\models\Lemma), Object(Doctrine\ORM\PersistentCollection), Object(Doctrine\ORM\EntityManager))
#3 /usr/local/zend/apache2/htdocs/doctrine/lib/Doctrine/ORM/PersistentCollection.php(495): Doctrine\ORM\PersistentCollection->_initialize()
#4 /usr/local/zend/apache2/htdocs/kateglo/application/views/scripts/search/index.phtml(24): Doctrine\ORM\PersistentCollection->getIterator()

@roman: i send you the new database structure and the php code (models etc..)

@doctrinebot
Copy link
Author

Comment created by purnama:

This is the SQL statement produce by
$this->_getSelectManyToManyEntityCollectionSql($assoc, $criteria)

on line 474:

SELECT type_id, type_name, type_abbreviation FROM type INNER JOIN lemma_type ON type. = lemma_type.type_id WHERE lemma_type.lemma_id = NULL;

as you can see the syntax after ON is failure its type. with dot.

@doctrinebot
Copy link
Author

Comment created by purnama:

Hallo,

I try to fix this issue myself. i send you the patch code right after this.

for the info. i change my manytomany mapping like this

/****
* @var kateglo\application\helpers\collections\ArrayCollection
* @manytomany(targetEntity="kateglo\application\models\Lemma")
* @jointable(name="lemma_type",
* joinColumns={@joincolumn(name="type_id", referencedColumnName="id")},
* inverseJoinColumns={@joincolumn(name="lemma_id", referencedColumnName="lemma")}
* )
*/

as you cann see the referencedColumnName did not referenced to column name in the database, but the member variable of the Entity class. or something like that. i dont understand :) but this is incosequent. maybe on later fix.. but i go on with this right now.

@doctrinebot
Copy link
Author

Comment created by romanb:

This should be fixed now in trunk. If not, please reopen this issue with new information. Thanks for reporting!

@doctrinebot
Copy link
Author

Comment created by purnama:

Hello,

Thank You for the patch.

But its still not functioning. I think you need to see my patch file that is attached to this issue.

There is two other problems that to be fix on many to many. the first one is ambigous table name problem (my relation table have the same column name as his parent table for foreign key.

the secod problem is the referencedColumnId name must be a class name or something.

only if i do this patch i can go on.

please take a look.

regards,
Arthur

@doctrinebot
Copy link
Author

Comment created by romanb:

Just to be sure, did you revert your local changes, using only the original latest code from trunk and changing back your annotations to the "right way" (column names)?

Like I said, I reproduced the issue in our tests and fixed it. I am no longer able to reproduce it.

Please add a new, failing test here: http://trac.doctrine-project.org/browser/trunk/tests/Doctrine/Tests/ORM/Functional/AdvancedAssociationTest.php

Add missing models, if necessary, and then attach a diff to this ticket.

Thanks!

@doctrinebot
Copy link
Author

Comment created by romanb:

I think I see the issue with the ambigious table name but the other problem should be fixed already.

@doctrinebot
Copy link
Author

Comment created by romanb:

I'm working on it and will get back to you shortly.

Thanks for your patience.

@doctrinebot
Copy link
Author

Comment created by romanb:

Please try the latest code from trunk now and report back. Thanks!

@doctrinebot
Copy link
Author

Comment created by purnama:

Hello,

Hier i send you a patch file for testing the ManyToMany problem. i hope this help.
I see that you already working on that.

Thank you very much.

@doctrinebot
Copy link
Author

Comment created by purnama:

Ok it works,

Thank You.

@doctrinebot
Copy link
Author

Comment created by romanb:

I added your new test to our suite! Thank you!

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.0-ALPHA3 milestone Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@doctrinebot
Copy link
Author

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

No branches or pull requests

1 participant