DDC-2394: QueryExpressionVisitor has no implementation of Comparison::CONTAINS #3004

Closed
opened 2026-01-22 14:09:36 +01:00 by admin · 11 comments
Owner

Originally created by @doctrinebot on GitHub (Apr 8, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user bguery:

$criteria = Criteria::create();
$criteria
    ->andWhere(
        $criteria->expr()->contains('r.body', 'foo')
    )
;

$entities = $repo->createQueryBuilder()->addCriteria($criteria)->getQuery()->getResult();

Throws the following exception:

javaRuntimeException: Unknown comparison operator: CONTAINS

I except it to properly handle the CONTAINS comparison and result in a LIKE operator.


I added a failing test case & a fix there: https://github.com/borisguery/doctrine2/tree/DDC-2394

Originally created by @doctrinebot on GitHub (Apr 8, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user bguery: ``` $criteria = Criteria::create(); $criteria ->andWhere( $criteria->expr()->contains('r.body', 'foo') ) ; $entities = $repo->createQueryBuilder()->addCriteria($criteria)->getQuery()->getResult(); ``` Throws the following exception: `javaRuntimeException: Unknown comparison operator: CONTAINS` I except it to properly handle the `CONTAINS` comparison and result in a `LIKE` operator. --- I added a failing test case & a fix there: https://github.com/borisguery/doctrine2/tree/[DDC-2394](http://www.doctrine-project.org/jira/browse/DDC-2394)
admin added the Bug label 2026-01-22 14:09:36 +01:00
admin closed this issue 2026-01-22 14:09:36 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 14, 2013):

Comment created by @beberlei:

This was added in 2.4, you are probably using Collections 1.1 with ORM 2.3, where this occurs.

@doctrinebot commented on GitHub (Apr 14, 2013): Comment created by @beberlei: This was added in 2.4, you are probably using Collections 1.1 with ORM 2.3, where this occurs.
Author
Owner

@doctrinebot commented on GitHub (Apr 14, 2013):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Apr 14, 2013): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Sep 16, 2013):

Comment created by mnapoli:

Apparently it wasn't, I'm on 2.4 and still get the exception.

I submitted a PR: https://github.com/doctrine/doctrine2/pull/791

@doctrinebot commented on GitHub (Sep 16, 2013): Comment created by mnapoli: Apparently it wasn't, I'm on 2.4 and still get the exception. I submitted a PR: https://github.com/doctrine/doctrine2/pull/791
Author
Owner

@doctrinebot commented on GitHub (Oct 11, 2013):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-791] was closed:
https://github.com/doctrine/doctrine2/pull/791

@doctrinebot commented on GitHub (Oct 11, 2013): Comment created by @doctrinebot: A related Github Pull-Request [GH-791] was closed: https://github.com/doctrine/doctrine2/pull/791
Author
Owner

@doctrinebot commented on GitHub (May 27, 2014):

Comment created by althaus:

As this issue confused me, I took a look into it and the reason seems to be that there's no current release of doctrine/orm including this bugfix. It's not part of the current v2.4.2 tag:

https://github.com/doctrine/doctrine2/blob/v2.4.2/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php

We'd be really happy to get a new bugfix release.

Running those lib versions:

doctrine/annotations v1.1.2 Docblock Annotations Parser
doctrine/cache v1.3.0 Caching library offering an object-oriented API for many cache b...
doctrine/collections v1.2 Collections Abstraction library
doctrine/common v2.4.2 Common Library for Doctrine projects
doctrine/data-fixtures v1.0.0 Data Fixtures for all Doctrine Object Managers
doctrine/dbal v2.4.2 Database Abstraction Layer
doctrine/doctrine-bundle v1.2.0 Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle v2.2.0 Symfony DoctrineFixturesBundle
doctrine/inflector v1.0 Common String Manipulations with regard to casing and singular/p...
doctrine/lexer v1.0 Base library for a lexer that can be used in Top-Down, Recursive...
doctrine/orm v2.4.2 Object-Relational-Mapper for PHP

@doctrinebot commented on GitHub (May 27, 2014): Comment created by althaus: As this issue confused me, I took a look into it and the reason seems to be that there's no current release of doctrine/orm including this bugfix. It's not part of the current v2.4.2 tag: https://github.com/doctrine/doctrine2/blob/v2.4.2/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php We'd be really happy to get a new bugfix release. Running those lib versions: doctrine/annotations v1.1.2 Docblock Annotations Parser doctrine/cache v1.3.0 Caching library offering an object-oriented API for many cache b... doctrine/collections v1.2 Collections Abstraction library doctrine/common v2.4.2 Common Library for Doctrine projects doctrine/data-fixtures v1.0.0 Data Fixtures for all Doctrine Object Managers doctrine/dbal v2.4.2 Database Abstraction Layer doctrine/doctrine-bundle v1.2.0 Symfony DoctrineBundle doctrine/doctrine-fixtures-bundle v2.2.0 Symfony DoctrineFixturesBundle doctrine/inflector v1.0 Common String Manipulations with regard to casing and singular/p... doctrine/lexer v1.0 Base library for a lexer that can be used in Top-Down, Recursive... doctrine/orm v2.4.2 Object-Relational-Mapper for PHP
Author
Owner

@doctrinebot commented on GitHub (May 27, 2014):

Comment created by @ocramius:

[~althaus] this is a new feature, it won't be backported as bugfix.

@doctrinebot commented on GitHub (May 27, 2014): Comment created by @ocramius: [~althaus] this is a new feature, it won't be backported as bugfix.
Author
Owner

@doctrinebot commented on GitHub (May 27, 2014):

Comment created by mnapoli:

[~ocramius] I would rather say it's a bug because the feature works with ArrayCollection. It was something missing in the implementation in the ORM. The feature is offered by the interface of the Criteria, so the ORM implementation should support it (else the Collection abstraction is useless).

@doctrinebot commented on GitHub (May 27, 2014): Comment created by mnapoli: [~ocramius] I would rather say it's a bug because the feature works with ArrayCollection. It was something missing in the implementation in the ORM. The feature is offered by the interface of the Criteria, so the ORM implementation should support it (else the Collection abstraction is useless).
Author
Owner

@doctrinebot commented on GitHub (May 27, 2014):

Comment created by @ocramius:

[~mnapoli] the criteria expressions support depends on the visitor implementation.
They are not interfaced, and custom expression types are also accepted.

@doctrinebot commented on GitHub (May 27, 2014): Comment created by @ocramius: [~mnapoli] the criteria expressions support depends on the visitor implementation. They are not interfaced, and custom expression types are also accepted.
Author
Owner

@doctrinebot commented on GitHub (May 27, 2014):

Comment created by mnapoli:

Beyond code interface, I rather mean "contract" between the library and the user.

The criteria's purpose is a query API that works both on persistent and non-persistent collections: it abstracts the persistence away. By having differences in implementation, the main purpose of the criteria is lost, which IMO is a bug.

@doctrinebot commented on GitHub (May 27, 2014): Comment created by mnapoli: Beyond code interface, I rather mean "contract" between the library and the user. The criteria's purpose is a query API that works both on persistent and non-persistent collections: it abstracts the persistence away. By having differences in implementation, the main purpose of the criteria is lost, which IMO is a bug.
Author
Owner

@doctrinebot commented on GitHub (May 27, 2014):

Comment created by @ocramius:

[~mnapoli] there are actually various implementations that just don't support many of the operations (wrote some cache-based adapters and some Zend\Db ones as well). It's just an unsupported case in this version, it is not a bug.

@doctrinebot commented on GitHub (May 27, 2014): Comment created by @ocramius: [~mnapoli] there are actually various implementations that just don't support many of the operations (wrote some cache-based adapters and some Zend\Db ones as well). It's just an unsupported case in this version, it is not a bug.
Author
Owner

@doctrinebot commented on GitHub (Jun 3, 2014):

Comment created by althaus:

I can understand both sides, but it's a pity that the QueryExpressionVisitor has such issues with the Criteria API (which is basically quite nice). We've just build some complex filter management around the Criteria API and now it seems more and more like a bad decision.

@doctrinebot commented on GitHub (Jun 3, 2014): Comment created by althaus: I can understand both sides, but it's a pity that the QueryExpressionVisitor has such issues with the Criteria API (which is basically quite nice). We've just build some complex filter management around the Criteria API and now it seems more and more like a bad decision.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3004