Bug #33397
Difference for ManyToMany with JoinTable annotation and without
| Status: | Resolved | Start date: | 2012-01-23 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | Karsten Dambekalns | % Done: | 100% |
|
| Category: | Persistence | |||
| Target version: | TYPO3 Flow Base Distribution - 2.0 beta 1 | |||
| PHP Version: | Complexity: | |||
| Has patch: | No | FLOW3 version affected: | FLOW3 1.1.0 beta 2 | |
| Votes: | 0 |
Description
There is a difference between joinColumn creation with JoinTable annotation and without for ManyToMany relations. In case there is a JoinTable annotation (and no options for columns are set) the automatic creation inverses the columns so the join works but the columns are named wrong / used wrong.
So if you join class A and Class B the resulting join table will have columns for A identifier and B identifier but the inserted identifiers are exactly the opposite. This does not happen if the JoinTable Annotation is dropped completely.
Thanks to Kira Backes for noticing.
The fix is simple but probably a breaking change.
Associated revisions
[!!!][BUGFIX] Misused JoinColumns in ManyToMany
With this fix the JoinColumns are created and used in the same
way regardless if you have a JoinTable annotation.
This is (almost) a cosmetic fix as it works without, but can lead
to confusion if looking at the database.
Breaking change as the JoinColumns could change if you annotated
with JoinTable.
Change-Id: I826a89f7dccfc68cf53ec31fbe66929c02c0a70a
Fixes: #33397
Releases: 1.2
History
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8656
Updated by Gerrit Code Review over 1 year ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8656
Updated by Karsten Dambekalns over 1 year ago
- Category set to Persistence
- Assignee set to Christian Mueller
Thanks, I'll check.
Updated by Adrian Föder about 1 year ago
Just was affected by this one by myself; I have
1 /**
2 * @var \Doctrine\Common\Collections\Collection<\Acme\Rating\Domain\Model\Rating>
3 * @ORM\ManyToMany
4 * @ORM\JoinTable(inverseJoinColumns={@ORM\JoinColumn(unique=true)})
5 */
6 protected $ratings;
in order to achieve a OneToMany relation like described at Doctrine;
the resulting CREATE TABLE looks like
1 CREATE TABLE `acme_acme_domain_model_product_ratings_join` (
2 `rating_rating` varchar(40) NOT NULL,
3 `acme_product` varchar(40) NOT NULL,
4 PRIMARY KEY (`rating_rating`,`acme_product`),
5 UNIQUE KEY `UNIQ_DE76D5E47F43B426` (`acme_product`),
6 KEY `IDX_DE76D5E4F77B4CAA` (`rating_rating`),
7 CONSTRAINT `FK_DE76D5E47F43B426` FOREIGN KEY (`acme_product`) REFERENCES `acme_rating_domain_model_rating` (`flow3_persistence_identifier`),
8 CONSTRAINT `FK_DE76D5E4F77B4CAA` FOREIGN KEY (`rating_rating`) REFERENCES `acme_acme_domain_model_product` (`flow3_persistence_identifier`)
9 ) ENGINE=InnoDB DEFAULT CHARSET=utf8$$
Updated by Gerrit Code Review about 1 year ago
Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8656
Updated by Karsten Dambekalns about 1 year ago
- Target version set to 1.1
Updated by Karsten Dambekalns about 1 year ago
- Assignee changed from Christian Mueller to Karsten Dambekalns
Updated by Karsten Dambekalns 12 months ago
- Target version changed from 1.1 to 1.1 RC1
Updated by Karsten Dambekalns 11 months ago
- Target version changed from 1.1 RC1 to 2.0 beta 1
- FLOW3 version affected changed from Git master to FLOW3 1.1.0 beta 2
Updated by Gerrit Code Review 9 months ago
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
Updated by Gerrit Code Review 9 months ago
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
Updated by Gerrit Code Review 9 months ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
Updated by Gerrit Code Review 9 months ago
Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
Updated by Gerrit Code Review 9 months ago
Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
Updated by Gerrit Code Review 9 months ago
Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
Updated by Christian Mueller 9 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset f8b0bb7ac110f0e3c5d9fae6e252fc9e326b4da9.