Permalink
Browse files

Merge pull request #175 from cedriclombardot/fix-data-dump-with-object

Fix data dump with object
  • Loading branch information...
2 parents 9d6fa89 + 51d91fc commit abf90dd1fcbe5ae032b9758f3e2daba0dab06622 @willdurand willdurand committed Aug 22, 2012
View
1 .gitignore
@@ -2,3 +2,4 @@ Model/*/map
Model/*/om
vendor
composer.lock
+composer.phar
View
4 DataFixtures/Dumper/AbstractDataDumper.php
@@ -156,6 +156,10 @@ protected function getDataAsArray()
// We did not want auto incremented primary keys
$values[$col] = $row[$col];
}
+
+ if ($column->getType() == \PropelColumnTypes::OBJECT) {
+ $values[$col] = unserialize($row[$col]);
+ }
}
if (count($primaryKeys) > 1 || (count($primaryKeys) > 0 && count($foreignKeys) > 0)) {
View
5 Tests/DataFixtures/Dumper/YamlDataDumperTest.php
@@ -24,10 +24,14 @@ public function testYamlDump()
$author = new \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor();
$author->setName('A famous one')->save($this->con);
+ $complementary = new \stdClass();
+ $complementary->first_word_date = '2012-01-01';
+
$book = new \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\Book();
$book
->setName('An important one')
->setAuthorId(1)
+ ->setComplementaryInfos($complementary)
->save($this->con)
;
@@ -46,6 +50,7 @@ public function testYamlDump()
id: '1'
name: 'An important one'
author_id: BookAuthor_1
+ complementary_infos: !!php/object:O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";}
YAML;
View
1 Tests/DataFixtures/TestCase.php
@@ -42,6 +42,7 @@ protected function setUp()
<column name="name" type="varchar" size="255" />
<column name="description" type="varchar" />
<column name="author_id" type="integer" required="false" defaultValue="null" />
+ <column name="complementary_infos" required="false" type="object" description="An object column" />
<foreign-key foreignTable="book_author" onDelete="RESTRICT" onUpdate="CASCADE">
<reference local="author_id" foreign="id" />

0 comments on commit abf90dd

Please sign in to comment.