DDC-1341: MultiTableUpdateExecutor does not bind parameters properly #1680

Closed
opened 2026-01-22 13:22:06 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Aug 21, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user pave.kucera:

Hi, I found really annoing bug in multi table update executor, it doesn't bind parameters properly. I have following structure of entities (afaik not really important, bug should appear with any class inheritance structure)

/****
* @entity
* @inheritanceType("JOINED")
* @discriminatorColumn(name="type", type="string")
* @discriminatorMap({"NodeEntity", forum = "ForumEntity"})
*/
class NodeEntity
{
  // ... some params
}

/****
* @entity
*/
class ForumEntity
{
/****
* @manyToOne(targetEntity="Author")
*/
private $lastPostAuthor;


/****
* @column(type="datetime")
*/
private $tLastPost;
// ... some params
}

And I'm trying to run following query

$qb = $this->entityManager->createQueryBuilder()
            ->update('ForumEntity', 'f')
            ->set('f.nPosts', 'f.nPosts + 1')
            ->set('f.tLastPost', ':tLastPost')->setParameter('tLastPost', $post->getTCreation()) // $post->getTCreation() returns an instance of DateTime
            ->set('f.lastPostAuthor', ':author')->setParameter('author', $post->getAuthor()) // $post->getAuthor() returns an instance of AuthorEntity

            ->where('f.lft <= :left')->setParameter('left', $forum->getLft())
            ->andWhere('f.rgt >= :right')->setParameter('right', $forum->getRgt())
            ->andWhere('f.root = :root')->setParameter('root', $forum->getRoot());

        $qb->getQuery()->execute();

Which fails with "recoverable error", because Doctrine tries to convert value of parameter 'right' to datetime. I have learned why it does so, it is because of line 157 in already mentioned MultiTableUpdateExecutor - while parameters for the insert query are sliced of parameters from update clause, their types are not. And that is a bit problematic.

But that is not the only problem, if you look at line 161, the update query receives parameters as they were binded to QueryBuilder, so when I bind there an object, the update query receives the object instead of his identificator. That leads to error like "object ... could not be converted to string". And also, the update query does not receive any information about type of parameters, but I'm not sure if that is also a bug.

I'm not a native english speaker so if I explain things chaotically, just say so please, I'll try better :).

Originally created by @doctrinebot on GitHub (Aug 21, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user pave.kucera: Hi, I found really annoing bug in multi table update executor, it doesn't bind parameters properly. I have following structure of entities (afaik not really important, bug should appear with any class inheritance structure) ``` java /**** * @entity * @inheritanceType("JOINED") * @discriminatorColumn(name="type", type="string") * @discriminatorMap({"NodeEntity", forum = "ForumEntity"}) */ class NodeEntity { // ... some params } /**** * @entity */ class ForumEntity { /**** * @manyToOne(targetEntity="Author") */ private $lastPostAuthor; /**** * @column(type="datetime") */ private $tLastPost; // ... some params } ``` And I'm trying to run following query ``` java $qb = $this->entityManager->createQueryBuilder() ->update('ForumEntity', 'f') ->set('f.nPosts', 'f.nPosts + 1') ->set('f.tLastPost', ':tLastPost')->setParameter('tLastPost', $post->getTCreation()) // $post->getTCreation() returns an instance of DateTime ->set('f.lastPostAuthor', ':author')->setParameter('author', $post->getAuthor()) // $post->getAuthor() returns an instance of AuthorEntity ->where('f.lft <= :left')->setParameter('left', $forum->getLft()) ->andWhere('f.rgt >= :right')->setParameter('right', $forum->getRgt()) ->andWhere('f.root = :root')->setParameter('root', $forum->getRoot()); $qb->getQuery()->execute(); ``` Which fails with "recoverable error", because Doctrine tries to convert value of parameter 'right' to datetime. I have learned why it does so, it is because of line 157 in already mentioned MultiTableUpdateExecutor - while parameters for the insert query are sliced of parameters from update clause, their types are not. And that is a bit problematic. But that is not the only problem, if you look at line 161, the update query receives parameters as they were binded to QueryBuilder, so when I bind there an object, the update query receives the object instead of his identificator. That leads to error like "object ... could not be converted to string". And also, the update query does not receive any information about type of parameters, but I'm not sure if that is also a bug. I'm not a native english speaker so if I explain things chaotically, just say so please, I'll try better :).
admin added the Bug label 2026-01-22 13:22:06 +01:00
admin closed this issue 2026-01-22 13:22:08 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 28, 2011):

Comment created by @beberlei:

Assigned to Guilherme

@doctrinebot commented on GitHub (Aug 28, 2011): Comment created by @beberlei: Assigned to Guilherme
Author
Owner

@doctrinebot commented on GitHub (Aug 28, 2011):

Comment created by @guilhermeblanco:

Fixed since this commit: e7f471ef3e

@doctrinebot commented on GitHub (Aug 28, 2011): Comment created by @guilhermeblanco: Fixed since this commit: https://github.com/doctrine/doctrine2/commit/e7f471ef3e1ffa5e180623115a45f423572549e4
Author
Owner

@doctrinebot commented on GitHub (Aug 28, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 28, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Aug 28, 2011):

Comment created by @beberlei:

Merged into 2.1.x

@doctrinebot commented on GitHub (Aug 28, 2011): Comment created by @beberlei: Merged into 2.1.x
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1680