Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4
-
Fix Version/s: None
-
Component/s: Connection, Data Fixtures
-
Labels:None
-
Environment:symfony 1.4.6, windows 7, apache2.2, php5.3.3, mySQL 5.1.49-community
Description
I don't know where exactly to start, I'm new here, and i'm not even sure this is a bug. BUT
We have a database structure with most important tables' PK's as string fields, which function as FK on other tables the basic structure is:
Artist
-Album
-Song
-Comments
each artist has multiple songs
each artist has multiple albums
each album has multiple songs that belong to the same artist as the album belongs to
each song has multiple comments
thus, the UnitOfWork - builtFlushTree should generate
[0]=>Artist
[1]=>Album
[2]=>Song
[3]=>Comments
but instead i get:
[0] => Album
[1] => Artist
[2] => Song
[3] => Lyrics
which in turn generates:
QLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`lyrics`.`album`, CONSTRAINT `album_artist_fk_stripped_name_artist_stripped_name` FOREIGN KEY (`artist_fk_stripped_name`) REFERENCES `artist` (`stripped_name`) ON DELETE CASCADE ON UPDATE CASC)
obviously.
I've been going through symfony/doctrine code for a whole day trying to figure out why I can't load-data. in the end i get to this buildFlushTree function.
probably have to go deeper. but so far this is it
PS. It's my decision to use string fields as PK's and FK even though it's a bad practice, but just because it is a bad practice I shouldn't be unable to work with it.
found a tiny BUG, submitting the fix.
EDIT: scratch the rest from here.
<!-----------
still, fixing the bug does not resolve the issue
BECAUSE:
the whole logic of ordering the tables is flawed! it can be proved, don't have time to do so. but trying to come up with a fix myself
instead of looping through the tables and then through each tables' related tables, either have a recursive function OR implement user defined array sort function, latter of which seems like the proper and correct way to go
-->