/**
  * Returns the passed query after rewriting the DISTINCT clause, so that drivers
  * that do not support the "ON" part can provide the actual way it should be done
  *
  * @param Query $query The query to be transformed
  * @return Query
  */
 protected function _transformDistinct($query)
 {
     if (is_array($query->clause('distinct'))) {
         $query->group($query->clause('distinct'), true);
         $query->distinct(false);
     }
     return $query;
 }