1
0
mirror of synced 2025-01-18 14:31:40 +03:00

DDC-856 - Add default "string" type to discriminator column, throw exception on specification of a bunch of invalid types

This commit is contained in:
Benjamin Eberlei 2010-11-11 21:13:03 +01:00
parent ac85584e9b
commit 4ea3277c28
2 changed files with 13 additions and 0 deletions

View File

@ -1442,6 +1442,13 @@ class ClassMetadataInfo
if ( ! isset($columnDef['fieldName'])) {
$columnDef['fieldName'] = $columnDef['name'];
}
if ( ! isset($columnDef['type'])) {
$columnDef['type'] = "string";
}
if (in_array($columnDef['type'], array("boolean", "array", "object", "datetime", "time", "date"))) {
throw MappingException::invalidDiscriminatorColumnType($this->name, $columnDef['type']);
}
$this->discriminatorColumn = $columnDef;
}
}

View File

@ -207,6 +207,11 @@ class MappingException extends \Doctrine\ORM\ORMException
return new self("Entity class '$className' is using inheritance but no discriminator column was defined.");
}
public static function invalidDiscriminatorColumnType($className, $type)
{
return new self("Discriminator column type on entity class '$className' is not allowed to be '$type'. 'string' or 'integer' type variables are suggested!");
}
/**
* @param string $className
* @param string $columnName
@ -216,4 +221,5 @@ class MappingException extends \Doctrine\ORM\ORMException
{
return new self("Duplicate definition of column '".$columnName."' on entity '".$className."' in a field or discriminator column mapping.");
}
}