Ticket #1383 (closed defect: fixed)
Doctrine_Validator throws unnecessary exception with subclass
| Reported by: | jupaju | Owned by: | jwage |
|---|---|---|---|
| Priority: | critical | Milestone: | |
| Component: | Validators | Version: | 0.11.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
Doctrine_Validator throws validation exception for field 'owner_type' in class 'Image' being null when trying to save a new record with the subclass Brand_Image in following setup: (I've removed unrelated fields/relations/indexes of class definitions to simplify)
Class definitions:
class Image extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('id', 'integer', null, array('primary' => true, 'sequence' => true));
$this->hasColumn('owner_id', 'integer', null, array('notnull' => true));
$this->hasColumn('owner_type', 'integer', 5, array('notnull' => true));
$this->hasColumn('name', 'string', 128, array('notnull' => true, 'unique' => true));
$this->setSubclasses(array(
'Manufacturer_Image' => array('owner_type' => 1),
'Brand_Image' => array('owner_type' => 2),
'Category_Image' => array('owner_type' => 3),
'Family_Image' => array('owner_type' => 4),
'Product_Image' => array('owner_type' => 5),
'Productversion_Image' => array('owner_type' => 6)
));
}
}
class Brand_Image extends Image
{
}
class Brand extends Doctrine_Record
{
public function setTableDefinition() {
$this->hasColumn('id', 'integer', null, array('primary' => true, 'sequence' => true));
$this->hasColumn('name', 'string', 255, array('notnull' => true));
}
public function setUp() {
$this->hasMany(
'Brand_Image',
array(
'local' => 'id',
'foreign' => 'owner_id'
)
);
}
}
Use case resulting exception:
$brand = new Brand; $brand->name = 'The Great Brand'; $brand->Brand_Image[0]->name = 'imagename'; $brand->save();
But actually owner_type is not null altough it's not set by user as Doctrine sets the value automatically as defined in subclasses-definition.
Change History
Note: See
TracTickets for help on using
tickets.