Doctrine 1
  1. Doctrine 1
  2. DC-957

MSSQL doctrine inner join group by problem

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      mssql, doctrine 1.2.3 , symfony

      Description

      http://www.doctrine-project.org/projects/orm/1.2/docs/manual/dql-doctrine-query-language/en#group-by,-having-clauses

      $q = Doctrine_Query::create()
      ->select('u.username')
      ->addSelect('COUNT(p.id) as num_phonenumbers')
      ->from('User u')
      ->leftJoin('u.Phonenumbers p')
      ->groupBy('u.id');

      SELECT
      u.id AS u__id,
      u.username AS u__username,
      COUNT(p.id) AS p__0
      FROM user u
      LEFT JOIN phonenumber p ON u.id = p.user_id
      GROUP BY u.id

      i should create

      SELECT
      COUNT(p.id) AS p__0
      FROM user u
      LEFT JOIN phonenumber p ON u.id = p.user_id
      GROUP BY u.id

      MSSQL doesnt support this use of group by sql. Id have to be in aggregrate function or group by. I do not need id but doctrine creates it in sql.

      "invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Mehmet Uysal
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: