Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2394

QueryExpressionVisitor has no implementation of Comparison::CONTAINS

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: Git Master
    • Fix Version/s: None
    • Component/s: ORM
    • Environment:
      n/a

      Description

      Use case
      $criteria = Criteria::create();
      $criteria
          ->andWhere(
              $criteria->expr()->contains('r.body', 'foo')
          )
      ;
      
      $entities = $repo->createQueryBuilder()->addCriteria($criteria)->getQuery()->getResult();
      

      Throws the following exception:

      RuntimeException: 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

        Activity

        Hide
        Matthieu Napoli added a comment -

        Marco Pivetta 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).

        Show
        Matthieu Napoli added a comment - Marco Pivetta 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).
        Hide
        Marco Pivetta added a comment -

        Matthieu Napoli the criteria expressions support depends on the visitor implementation.
        They are not interfaced, and custom expression types are also accepted.

        Show
        Marco Pivetta added a comment - Matthieu Napoli the criteria expressions support depends on the visitor implementation. They are not interfaced, and custom expression types are also accepted.
        Hide
        Matthieu Napoli added a comment -

        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.

        Show
        Matthieu Napoli added a comment - 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.
        Hide
        Marco Pivetta added a comment -

        Matthieu Napoli 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.

        Show
        Marco Pivetta added a comment - Matthieu Napoli 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.
        Hide
        Matthias Althaus added a comment -

        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.

        Show
        Matthias Althaus added a comment - 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.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Boris Guéry
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: