#1383: Doctrine_Validator throws unnecessary exception with subclass
-----------------------------------+----------------------------------------
 Reporter:  jupaju                 |       Owner:  jwage  
     Type:  defect                 |      Status:  new    
 Priority:  critical               |   Milestone:  Unknown
Component:  Validators             |     Version:  0.11   
 Keywords:                         |    Has_test:  0      
 Mystatus:  Pending Core Response  |   Has_patch:  0      
-----------------------------------+----------------------------------------
 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.

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1383>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to