Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-478

$qb->expr()->between("alias.myfield", $minValue, $maxValue) cannot be parsed into valid SQL

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-BETA1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Debian 5.0, PostgreSql 8.4.2, PHP 5.3.1 (x86-64)

      Description

      When using the between() method of the Doctrine\ORM\Query\Expr class, an instance of Doctrine\ORM\Query\Expr\Func is returned, which produces a DQL similar to:

      SELECT p FROM MyTest\Domain\Person p WHERE BETWEEN(p.id, 1, 100)

      This is expected behaviour following the test available in Doctrine/Tests/ORM/Query/ExprTest.php, unfortunately the parser itself as well as other testcases expect the format to be

      SELECT p FROM MyTest\Domain\Person p WHERE p.id BETWEEN 1 AND 100

      So every time you call getSql() Doctrine throws an Exception because it tries to access BETWEEN() as a database function, whereas it really is a comparator.

      I made a quick fix available at http://www.pastie.org/888251 to solve this issue by keeping the parser as-is and only rewriting the returned class

      HTH

      Regards,
      Michael

      1. Between.php
        1 kB
        Michael Zach
      2. Expr.php
        17 kB
        Michael Zach
      3. Func.php
        2 kB
        Michael Zach

        Activity

        Hide
        Michael Zach added a comment - - edited

        Attached modified classes for easier review

        Show
        Michael Zach added a comment - - edited Attached modified classes for easier review
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Michael Zach
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: