Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1858

LIKE and IS NULL operators not supported in HAVING clause

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.5
    • Component/s: DQL
    • Security Level: All
    • Labels:
      None
    • Environment:
      Win7, Mysql

      Description

      The LIKE and IS NULL operators are not supported in HAVING clause.

      Work:
      SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu in (3,6)
      SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu = 3
      SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu >= 3
      ...

      Don't work:
      SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu LIKE 3
      SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu IS NULL
      SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu IS NOT NULL

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Assigned fix version

        Show
        Benjamin Eberlei added a comment - Assigned fix version
        Hide
        Litz Ouille added a comment -

        It works. Thanks !

        Show
        Litz Ouille added a comment - It works. Thanks !
        Hide
        Guilherme Blanco added a comment -

        I implemented support for ResultVariable in LikeExpression as of https://github.com/doctrine/doctrine2/commit/43fc8bafa766b4e924b05c74825dd30393a17f06

        Show
        Guilherme Blanco added a comment - I implemented support for ResultVariable in LikeExpression as of https://github.com/doctrine/doctrine2/commit/43fc8bafa766b4e924b05c74825dd30393a17f06
        Hide
        Litz Ouille added a comment -

        At the moment, only the `HAVING field IS [NOT] NULL` is working.

        The `HAVING field LIKE` as in
        (SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu LIKE 3)
        still does not work.

        Show
        Litz Ouille added a comment - At the moment, only the `HAVING field IS [NOT] NULL` is working. The `HAVING field LIKE` as in (SELECT _a.id, count(_photos) as uuuu FROM Acme\CoreBundle\Entity\Member _a LEFT JOIN _a.photos _photos GROUP BY _a HAVING uuuu LIKE 3) still does not work.
        Hide
        Guilherme Blanco added a comment -

        Functionality is already implemented in master as per coverage added in here:

        https://github.com/doctrine/doctrine2/commit/4e99c5c127c810bf63c9a371f87f0ff5c82e3e79

        Closing the ticket.

        Show
        Guilherme Blanco added a comment - Functionality is already implemented in master as per coverage added in here: https://github.com/doctrine/doctrine2/commit/4e99c5c127c810bf63c9a371f87f0ff5c82e3e79 Closing the ticket.

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            PETIT Yoann
          • Votes:
            4 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: