BUGFIX YamlFixture::writeDataObject() - some databases need special allowance to edit the primary key column - do so by using DB::getConn()->allowPrimaryKeyEditing()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100393 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-03-03 02:17:25 +00:00 committed by Sam Minnee
parent f851803652
commit 7937f5d7cc

View File

@ -175,7 +175,12 @@ class YamlFixture extends Object {
// Call $this->write(). (For example, in FileTest)
if(isset($fields['ID'])) {
$obj->ID = $fields['ID'];
// The database needs to allow inserting values into the foreign key column (ID in our case)
$conn = DB::getConn();
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing($dataClass, true);
$obj->write(false, true);
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing($dataClass, false);
}
// Populate the dictionary with the ID