@ManyToMany relation matching criteria ignores isNull(column) #4958

Closed
opened 2026-01-22 14:54:06 +01:00 by admin · 6 comments
Owner

Originally created by @RusAlex on GitHub (Jan 4, 2016).

I have an entity class where ManyMany relation described.

Then Im trying to do something like

public function getActiveRel()
{
   $criteria = Criteria::create()
   ->where(Criteria::expr()->isNull('column'));

   return $this->rel->matching($criteria);
}

IsNull condition is ignored in SqlValueVisitor.php
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php#L57

And no any IS NULL in final SQL statement.

Originally created by @RusAlex on GitHub (Jan 4, 2016). I have an entity class where ManyMany relation described. Then Im trying to do something like ``` php public function getActiveRel() { $criteria = Criteria::create() ->where(Criteria::expr()->isNull('column')); return $this->rel->matching($criteria); } ``` IsNull condition is ignored in SqlValueVisitor.php https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Persisters/SqlValueVisitor.php#L57 And no any IS NULL in final SQL statement.
admin closed this issue 2026-01-22 14:54:08 +01:00
Author
Owner

@RusAlex commented on GitHub (Jan 4, 2016):

But documentation says , that isNull(x) must work:

http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#filtering-collections

@RusAlex commented on GitHub (Jan 4, 2016): But documentation says , that isNull(x) must work: http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#filtering-collections
Author
Owner

@waltertamboer commented on GitHub (Apr 11, 2016):

I can confirm that this is happening. I'm also experiencing this issue.

@waltertamboer commented on GitHub (Apr 11, 2016): I can confirm that this is happening. I'm also experiencing this issue.
Author
Owner

@oprokidnev commented on GitHub (Oct 10, 2019):

Still happening in 2k19.
In my case managed to solve by multiple collection transformation.

        $this->collection->matching(
            \Doctrine\Common\Collections\Criteria::create()
        )->matching(
            \Doctrine\Common\Collections\Criteria::create()->where(
                \Doctrine\Common\Collections\Criteria::expr()->isNull('deletedAt')
            )
        )

Problem is with
\Doctrine\ORM\Persisters\Collection\ManyToManyPersister::expandCriteriaParameters

It uses SqlValueVisitor that does not understand Comparison::EQ expression with null values.

@oprokidnev commented on GitHub (Oct 10, 2019): Still happening in 2k19. In my case managed to solve by multiple collection transformation. ```php $this->collection->matching( \Doctrine\Common\Collections\Criteria::create() )->matching( \Doctrine\Common\Collections\Criteria::create()->where( \Doctrine\Common\Collections\Criteria::expr()->isNull('deletedAt') ) ) ``` Problem is with `\Doctrine\ORM\Persisters\Collection\ManyToManyPersister::expandCriteriaParameters` It uses `SqlValueVisitor` that does not understand Comparison::EQ expression with null values.
Author
Owner

@ThomasLabstep commented on GitHub (Dec 17, 2019):

Still an issue.

ManyToMany + isNull Criteria is 100% not working.

Thx for the pointer to SqlValueVisitor.

I guess we need a little PR to add the use case to support isNull?

@ThomasLabstep commented on GitHub (Dec 17, 2019): Still an issue. ManyToMany + isNull Criteria is 100% not working. Thx for the pointer to SqlValueVisitor. I guess we need a little PR to add the use case to support isNull?
Author
Owner

@astronati commented on GitHub (Apr 12, 2023):

@beberlei news about this issue? @MatTheCat

@astronati commented on GitHub (Apr 12, 2023): @beberlei news about this issue? @MatTheCat
Author
Owner

@MatTheCat commented on GitHub (Apr 12, 2023):

Well #10587 is open so maintainers will look at it when they’ll got time.

@MatTheCat commented on GitHub (Apr 12, 2023): Well #10587 is open so maintainers will look at it when they’ll got time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4958