Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Invalid
-
Affects Version/s: 1.2.1
-
Fix Version/s: None
-
Component/s: Data Fixtures
-
Labels:None
-
Environment:Doctrine 1.2.1
MySQL 5.1.37
Description
Hi,
if you have a One-To-One Relationship which uses Primary Keys on both ends Doctrine screws up the relationship if you import the data from a data fixture.
Example:
DB contents:
User:
id|username|password
1|eins|eins
2|zwei|zwei
3||drei|drei
4|vier|vier
Contact:
id|name
1|eins
3|drei
Contact:
id|name
2|zwei
4|vier
{{
//schema.yml
User:
columns:
id:
primary: true
autoincrement: true
type: integer(4)
username: string(255)
password: string(255)
relations:
Contact:
local: id
foreign: id
foreignType: one
Contact:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
name:
type: string(255)
Contact2:
columns:
id:
type: integer(4)
primary: true
autoincrement: true
name:
type: string(255)
}}
./doctrine dump-data
{{
//data/fixtures/data.yml
Contact:
Contact_1:
name: eins
Contact_3:
name: drei
Contact2:
Contact2_2:
name: zwei
Contact2_4:
name: vier
User:
User_1:
username: eins
password: eins
User_2:
username: zwei
password: zwei
User_3:
username: drei
password: drei
User_4:
username: vier
password: vier
}}
./doctrine build-all-reload
DB contents:
User:
id|username|password
1|eins|eins
2|zwei|zwei
3||drei|drei
4|vier|vier
Contact:
id|name
1|eins
2|drei
Contact:
id|name
1|zwei
2|vier
Now the relations are broken.
Your ticket is hard to read, just for future reference it would be wise to make sure the issue is readable for us. Anyways, I had a look and your schema is incorrect. You have a foreign key but it is also set as primary and auto increment.