mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
f851803652
commit
7937f5d7cc
@ -175,7 +175,12 @@ class YamlFixture extends Object {
|
|||||||
// Call $this->write(). (For example, in FileTest)
|
// Call $this->write(). (For example, in FileTest)
|
||||||
if(isset($fields['ID'])) {
|
if(isset($fields['ID'])) {
|
||||||
$obj->ID = $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);
|
$obj->write(false, true);
|
||||||
|
if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing($dataClass, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate the dictionary with the ID
|
// Populate the dictionary with the ID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user