use PropelColumnTypes instead of hardcoded values
This commit is contained in:
parent
0443b6706c
commit
d6e4ed86d2
|
@ -10,10 +10,10 @@
|
|||
|
||||
namespace Propel\PropelBundle\DataFixtures\Dumper;
|
||||
|
||||
use Propel\PropelBundle\DataFixtures\AbstractDataHandler;
|
||||
use \PDO;
|
||||
use \Propel;
|
||||
|
||||
use Propel\PropelBundle\DataFixtures\AbstractDataHandler;
|
||||
use \PropelColumnTypes;
|
||||
|
||||
/**
|
||||
* Abstract class to manage a common logic to dump data.
|
||||
|
@ -148,16 +148,16 @@ abstract class AbstractDataDumper extends AbstractDataHandler implements DataDum
|
|||
$values[$col] = strlen($row[$col]) ? $relatedTable->getPhpName().'_'.$row[$col] : '';
|
||||
}
|
||||
} elseif (!$isPrimaryKey || ($isPrimaryKey && !$tableMap->isUseIdGenerator())) {
|
||||
if (!empty($row[$col]) && 'ARRAY' === $column->getType()) {
|
||||
if (!empty($row[$col]) && PropelColumnTypes::PHP_ARRAY === $column->getType()) {
|
||||
$serialized = substr($row[$col], 2, -2);
|
||||
$row[$col] = $serialized ? explode(' | ', $serialized) : array();
|
||||
$row[$col] = $serialized ? explode(' | ', $serialized) : array();
|
||||
}
|
||||
|
||||
// We did not want auto incremented primary keys
|
||||
$values[$col] = $row[$col];
|
||||
}
|
||||
|
||||
if ($column->getType() == \PropelColumnTypes::OBJECT) {
|
||||
if (PropelColumnTypes::OBJECT === $column->getType()) {
|
||||
$values[$col] = unserialize($row[$col]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Propel\PropelBundle\DataFixtures\Loader;
|
|||
use \BasePeer;
|
||||
use \BaseObject;
|
||||
use \Propel;
|
||||
use \PropelColumnTypes;
|
||||
use \PropelException;
|
||||
use Propel\PropelBundle\DataFixtures\AbstractDataHandler;
|
||||
use Propel\PropelBundle\Util\PropelInflector;
|
||||
|
@ -177,8 +178,9 @@ abstract class AbstractDataLoader extends AbstractDataHandler implements DataLoa
|
|||
continue;
|
||||
} catch (PropelException $e) {
|
||||
// Check whether this is actually an array stored in the object.
|
||||
if ('Cannot fetch TableMap for undefined table: '.substr($name, 0, -1) === $e->getMessage()) {
|
||||
if ('ARRAY' !== $tableMap->getColumn($name)->getType() && 'OBJECT' !== $tableMap->getColumn($name)->getType()) {
|
||||
if ('Cannot fetch TableMap for undefined table: ' . substr($name, 0, -1) === $e->getMessage()) {
|
||||
if (PropelColumnTypes::PHP_ARRAY !== $tableMap->getColumn($name)->getType()
|
||||
&& PropelColumnTypes::OBJECT !== $tableMap->getColumn($name)->getType()) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue