DDC-856 - Add default "string" type to discriminator column, throw exception on specification of a bunch of invalid types
This commit is contained in:
parent
ac85584e9b
commit
4ea3277c28
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.");
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user