Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: Query
    • Labels:
      None

      Description

      $limit = 10;
      $q = 'Me';
      $field = 'contractor';

      $q = Doctrine_Query::create()
      ->select(sprintf('DISTINCT PublicContract.%s', $field))
      ->from('PublicContract')
      ->where(sprintf('PublicContract.%s LIKE ?', $field), sprintf('%%%s%%', $q))
      ->limit($limit);

      The QUERY is WRONG:

      // SELECT DISTINCT p.id AS p_id, p.contractor AS p_contractor FROM public_contract p WHERE (p.contractor LIKE ?) LIMIT 10 - (%Me%)

      I can simply GROUP BY the contractor field, because DISTINCT can be considered as a special case of GROUP BY - and have the results I want:

      $q = Doctrine_Query::create()
      ->select(sprintf('PublicContract.%s', $field))
      ->from('PublicContract')
      ->where(sprintf('PublicContract.%s LIKE ?', $field), sprintf('%%%s%%', $q))
      ->groupBy(sprintf('PublicContract.%s', $field))
      ->limit($limit);

        Activity

        Hide
        Jonathan H. Wage added a comment -

        Test case or patch?

        Show
        Jonathan H. Wage added a comment - Test case or patch?

          People

          • Assignee:
            Guilherme Blanco
            Reporter:
            Mishal
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: