From 8f8a3b2f6e73695424d155fc4b987b029aa0f828 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 25 May 2010 03:49:22 +0000 Subject: [PATCH] BUGFIX YamlFixture::writeDataObject() - some databases need special allowance to edit the primary key column - do so by using DB::getConn()->allowPrimaryKeyEditing() (from r100393) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105558 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/YamlFixture.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dev/YamlFixture.php b/dev/YamlFixture.php index 2c68b3a16..6a11270b5 100644 --- a/dev/YamlFixture.php +++ b/dev/YamlFixture.php @@ -180,7 +180,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