Closed crantok closed 6 years ago
I would be as happy to see a workaround as I would to see a fix for this, just so I could get on with developing that part of my app.
I stripped out the foreign key mentioned in my first OP to make the table even simpler and the same behaviour (except for the foreign key violation) occurred.
Now, when my test data looks like this...
[
'details' => [
[ 'id' => 1 ],
[ 'id' => 2, 'derived_from_detail_id' => 1 ],
]
];
...I get this table content:
id | derived_from_detail_id |
---|---|
1 | NULL |
2 | NULL |
And when my test data looks like this...
[
'details' => [
[ 'id' => 1, 'derived_from_detail_id' => NULL ],
[ 'id' => 2, 'derived_from_detail_id' => 10 ],
]
];
...I then get this table content:
id | derived_from_detail_id |
---|---|
1 | NULL |
2 | 1 |
Is this intended behaviour?
If not then at least I now have a workaround, i.e. explicitly insert NULL values in to the first row of test data.
BTW, even though (in my OP) the relevant data never made it in to the DB, it still got far enough along the pipeline to cause a FK violation, which seems a bit crazy.
This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.
I have a two-column InnoDB MySQL table generated by
IdiormPhinx that looks like this...On the second column (called "derived_from_detail_id") is a foreign key constraint, so that any non-null values in that column must be present in the first column (called "id").
I can insert a row with a non-null value for "derived_from_detail_id" in PhpMyAdmin. Trying this in dbunit silently fails to insert the value of "derived_from_detail_id", which instead is NULL.
I'm using code copied (apart from the class name) from the MyApp_DbUnit_ArrayDataSet example in order to initialise tables with test data.
When my test data looks like this
...the tables are initialised as I expect them to be, i.e.
And when my test data looks like this...
...I get an appropriate error message, i.e.
But when my test data looks like this...
...I get still get this table content: