[PR #9430] Comparison when using false value has an error #11613

Closed
opened 2026-01-22 16:11:19 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/9430

State: closed
Merged: No


We had a project where we had the following:

    public function setDuplicate(int $id, bool $value): void
    {
        $this->_em
            ->createQueryBuilder()
            ->update(PotentialClient::class, 'w')
            ->set('w.duplicate', $value)
            ->where('w.id = :wId')
            ->setParameter('wId', $id)
            ->getQuery()
            ->execute();
    }

When called and setting $value to true, everything worked. When setting it to false, we get an exception from the DB because the statement ends up being w.duplicate = WHERE... I traced this to the __toString on the Comparision.php class.

This test causes that to be detected and fail. No fix offered as I wasn't sure what way that should be fixed, but I don't mind also including the fix if anyone here has suggestions on how to implement it.

I should point out that we 'fixed' this in our code by doing (int)$value when passing it to the ->set('w.duplicate', $value) call.

**Original Pull Request:** https://github.com/doctrine/orm/pull/9430 **State:** closed **Merged:** No --- We had a project where we had the following: ``` public function setDuplicate(int $id, bool $value): void { $this->_em ->createQueryBuilder() ->update(PotentialClient::class, 'w') ->set('w.duplicate', $value) ->where('w.id = :wId') ->setParameter('wId', $id) ->getQuery() ->execute(); } ``` When called and setting $value to true, everything worked. When setting it to false, we get an exception from the DB because the statement ends up being `w.duplicate = WHERE...` I traced this to the __toString on the Comparision.php class. This test causes that to be detected and fail. No fix offered as I wasn't sure what way that should be fixed, but I don't mind also including the fix if anyone here has suggestions on how to implement it. I should point out that we 'fixed' this in our code by doing `(int)$value` when passing it to the `->set('w.duplicate', $value)` call.
admin added the pull-request label 2026-01-22 16:11:19 +01:00
admin closed this issue 2026-01-22 16:11:20 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#11613