Bug #33397
Difference for ManyToMany with JoinTable annotation and without
Status: | Resolved | Start date: | 2012-01-23 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Karsten Dambekalns | % Done: | 100% |
|
Category: | Persistence | |||
Target version: | TYPO3 Flow Base Distribution - 2.0 beta 1 | |||
PHP Version: | Complexity: | |||
Has patch: | No | Affected Flow version: | FLOW3 1.1.0 beta 2 |
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
#1 Updated by Gerrit Code Review over 3 years 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
#2 Updated by Gerrit Code Review over 3 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8656
#3 Updated by Karsten Dambekalns over 3 years ago
- Category set to Persistence
- Assigned To set to Christian Müller
Thanks, I'll check.
#4 Updated by Adrian Föder over 3 years 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
1CREATE 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$$
#5 Updated by Gerrit Code Review over 3 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/8656
#6 Updated by Karsten Dambekalns over 3 years ago
- Target version set to 1.1
#7 Updated by Karsten Dambekalns about 3 years ago
- Assigned To changed from Christian Müller to Karsten Dambekalns
#8 Updated by Karsten Dambekalns about 3 years ago
- Target version changed from 1.1 to 1.1 RC1
#9 Updated by Karsten Dambekalns about 3 years ago
- Target version changed from 1.1 RC1 to 2.0 beta 1
- Affected Flow version changed from Git master to FLOW3 1.1.0 beta 2
#10 Updated by Gerrit Code Review almost 3 years ago
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
#11 Updated by Gerrit Code Review almost 3 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
#12 Updated by Gerrit Code Review almost 3 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
#13 Updated by Gerrit Code Review almost 3 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
#14 Updated by Gerrit Code Review almost 3 years ago
Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
#15 Updated by Gerrit Code Review almost 3 years ago
Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14141
#16 Updated by Christian Müller almost 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset f8b0bb7ac110f0e3c5d9fae6e252fc9e326b4da9.