[DDC-1652] ArrayHydrator with composite primary key Created: 15/Feb/12  Updated: 03/Mar/12  Resolved: 03/Mar/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.2.1
Security Level: All

Type: Bug Priority: Major
Reporter: Gandzy Ghennady Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None



Problem with ArrayHydrator and composite primary key.

Given the following data (PRIMARY KEY (`ancestor_id`,`descendant_id`))

ancestor_id descendant_id depth
1 1 0
1 2 1
$query = $em->createQuery("SELECT c,d FROM ResourceClosure c JOIN c.descendant d WHERE c.ancestor = 1");

echo 'ObjectHydrator result count = '.count($query->getResult()).PHP_EOL;
echo 'ArrayHydrator result count = '.count($query->getArrayResult()).PHP_EOL;
ObjectHydrator result count = 2 
ArrayHydrator result count = 1 

Expected both counts are equals 2.
In case getArrayResult() in result only first record hydrated, second record are ommited

Below examples model and insertion in db

 * @Entity
class ResourceClosure
     * @Id
     * @ManyToOne(targetEntity="Resource")
     * @JoinColumn(name="ancestor_id", referencedColumnName="id")
    private $ancestor;

     * @Id
     * @ManyToOne(targetEntity="Resource")
     * @JoinColumn(name="descendant_id", referencedColumnName="id")
     * @var Resource
    private $descendant;

     * @Column(name="depth", type="integer")
     * @var integer
    private $depth;
$resource1 = new Entity\Resource('resource1');

$resource2 = new Entity\Resource('resource2');


$closure1 = new Entity\ResourceClosure();


$closure2= new Entity\ResourceClosure();



Its work like expected in case entity ResourceClosure has simple primary key.

Comment by Benjamin Eberlei [ 20/Feb/12 ]


Comment by Benjamin Eberlei [ 20/Feb/12 ]

@Guilherme - This is because the SQL Walker decides to $addMetaColumns => false here. Why did we add this? This skips all meta columns in Array Results, i don't get what that is good for.

Comment by Benjamin Eberlei [ 20/Feb/12 ]

PR: https://github.com/doctrine/doctrine2/pull/290

Guilherme has to verify this

Comment by Guilherme Blanco [ 03/Mar/12 ]

Resolved with merge of https://github.com/doctrine/doctrine2/pull/290

Comment by Benjamin Eberlei [ 03/Mar/12 ]

Merged back to 2.2, will be in 2.2.1

Generated at Tue Dec 01 18:56:35 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.