DDC-979: ArrayHydrator::updateResultPointer() must be an array, string given #5513

Closed
doctrinebot opened this Issue Jan 12, 2011 · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user tbo:

I have the following MySQL tables + data

CREATE TABLE `agent` (
  `agentID` bigint(20) NOT NULL AUTO_INCREMENT,
  `company` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`agentID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='module=agent';

CREATE TABLE `file` (
  `fileID` bigint(20) NOT NULL AUTO_INCREMENT,
  `filename` varchar(100) DEFAULT NULL,
  `mimetype` varchar(100) DEFAULT NULL,
  `extension` varchar(5) DEFAULT NULL,
  `path` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`fileID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='module=agent';

CREATE TABLE `agentFile` (
  `agentID` bigint(20) NOT NULL COMMENT 'orderBy=orderNr&order=asc',
  `fileID` bigint(20) NOT NULL,
  `orderNr` int(11) DEFAULT NULL,
  PRIMARY KEY (`agentID`,`fileID`),
  KEY `agentFileAgent` (`agentID`),
  KEY `agentFileFile` (`fileID`),
  CONSTRAINT `agentFileAgent` FOREIGN KEY (`agentID`) REFERENCES `agent` (`agentID`) ON DELETE CASCADE ON UPDATE NO ACTION,
  CONSTRAINT `agentFileFile` FOREIGN KEY (`fileID`) REFERENCES `file` (`fileID`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='module=agent';


INSERT INTO `agent` (agentID,company) VALUES (1,'Company 1');
INSERT INTO `agent` (agentID,company) VALUES (2,'Company 2');
INSERT INTO `file` (fileID,filename,mimetype,extension,path) VALUES (1,'logoCompany2',NULL,NULL,NULL);
INSERT INTO `agentFile` (agentID,fileID,orderNr) VALUES (2,1,0);

Everything works fine if I do the following:

$query = $em->createQuery('SELECT a, af, f FROM Agent*Model_Agent a LEFT JOIN a._agentFileRefAgent af WITH af._orderNr=0 LEFT JOIN af.*file f');
$results = $query->getResult();

But I get an error when I replace getResult with getArrayResult.

$query = $em->createQuery('SELECT a, af, f FROM Agent*Model_Agent a LEFT JOIN a._agentFileRefAgent af WITH af._orderNr=0 LEFT JOIN af.*file f');
$results = $query->getArrayResult();

Error:

Catchable fatal error: Argument 1 passed to Doctrine\ORM\Internal\Hydration\ArrayHydrator::updateResultPointer() must be an array, string given, called in /var/www/vhost/issue/htdocs/externals/Doctrine/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php on line 150 and defined in /var/www/vhost/issue/htdocs/externals/Doctrine/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php on line 207
0.2773  12011956    Doctrine\ORM\AbstractQuery->getArrayResult( )   ../IndexController.php:18
0.2773  12012164    Doctrine\ORM\AbstractQuery->execute( )  ../AbstractQuery.php:378
0.3262  12217064    Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll( ) ../AbstractQuery.php:527
0.3263  12199568    Doctrine\ORM\Internal\Hydration\ArrayHydrator->_hydrateAll( )   ../AbstractHydrator.php:99
0.3276  12219368    Doctrine\ORM\Internal\Hydration\ArrayHydrator->_hydrateRow( )   ../ArrayHydrator.php:62
0.3277  12223840    Doctrine\ORM\Internal\Hydration\ArrayHydrator->updateResultPointer( )   ../ArrayHydrator.php:150
@doctrinebot

Comment created by @guilhermeblanco:

Could you please include your Model mappings too?

@doctrinebot

Comment created by @guilhermeblanco:

Hi,

This special situation is not really possible.
You are not allowed to create a cross-reference Entity without defining an own @Id.
The situation you exposed here is due to it. Issue was left open but now after some tests it can be closed. In 2.2-DEV we added a better explanation for your problem, I hope the message is clear enough for you:

Entity of type Doctrine\Tests\ORM\Functional\Ticket\DDC979AgentFile has identity through a foreign entity Doctrine\Tests\ORM\Functional\Ticket\DDC979Agent, however this entity has no identity itself. 
You have to call EntityManager#persist() on the related entity and make sure that an identifier was generated before trying to persist 'Doctrine\Tests\ORM\Functional\Ticket\DDC979AgentFile'. 
In case of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call EntityManager#flush() between both persist operations.

Marking the issue as won't fix.

@doctrinebot

Issue was closed with resolution "Won't Fix"

@doctrinebot

Comment created by @guilhermeblanco:

Added the testcase I have used.

@doctrinebot doctrinebot added this to the 2.2 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment