#1551: Subclass of column aggregation inheritance returns parent class instead 
of
subclass
-----------------------------------+----------------------------------------
 Reporter:  chorizo                |       Owner:  romanb 
     Type:  defect                 |      Status:  new    
 Priority:  minor                  |   Milestone:  Unknown
Component:  Query/Hydration        |     Version:  1.0.2  
 Keywords:                         |    Has_test:  0      
 Mystatus:  Pending Core Response  |   Has_patch:  1      
-----------------------------------+----------------------------------------
 I'm using a type column to define subclasses of a base type.  One of the
 subclasses has an additional subclass not determined by the type column.
 When I use that subclass table object to fetch objects, they are returned
 as the parent class instead of the subclass.

 For example:
 Base class: Object
 Column type subclasses: Page, File, Stylesheet (using the "type" column in
 the "object" table)
 Additional subclass: Template extends Page

 When I do a:
     $coll = Doctrine::getTable('Template')->createQuery()...
       ->execute();

 I get back "Page" objects instead of "Template" objects.

 This is a patch that fixes this problem:
 {{{
 Index: lib/Doctrine/Hydrator/RecordDriver.php
 ===================================================================
 --- lib/Doctrine/Hydrator/RecordDriver.php      (revision 8594)
 +++ lib/Doctrine/Hydrator/RecordDriver.php      (revision 8595)
 @@ -135,7 +135,11 @@
              if ( ! isset($data[$key]) || $data[$key] != $value) {
                  continue;
              } else {
 +              if (is_subclass_of($component, $table->getComponentName()))
 {
 +                return $component;
 +              } else {
                  return $table->getComponentName();
 +              }
              }
          }
          return $component;

 }}}

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1551>
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