Skip to content

Loading…

Fix data dump with object #175

Merged
merged 2 commits into from

3 participants

@cedriclombardot

Enable dumping columns object see : https://github.com/symfony/Yaml/blob/master/Tests/DumperTest.php#L159

And also ignore composer.phar to ensure never try to commit

Anh Tuan Kieu added some commits
@travisbot

This pull request fails (merged 51d91fc into 4980f54).

@cedriclombardot
@willdurand willdurand merged commit abf90dd into propelorm:1.1

1 check failed

Details default The Travis build failed
@willdurand
Propel member

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 20, 2012
  1. Ignore composer.phar

    Anh Tuan Kieu committed
  2. Fix yaml dumper for object columns

    Anh Tuan Kieu committed
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" />
Something went wrong with that request. Please try again.