Doctrine 1
  1. Doctrine 1
  2. DC-978

Doctrine_Connection_Mssql dies on modifyLimitSubquery every time


    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Connection
    • Labels:
    • Environment:


      Looking at the latest version of Doctrine_Connection_Mssql in git repo:

      In Doctrine_Query:getLimitSubquery() there is a call to Doctrine_Connection_Mssql::modifyLimitSubquery().

      public function modifyLimitSubquery(Doctrine_Table $rootTable, $query, $limit = false, $offset = false, $isManip = false)
      	return $this->modifyLimitQuery($query, $limit, $offset, $isManip, true);

      This in turn calls Doctrine_Connection_Mssql::modifyLimitQuery() wihtout passing the $queryOrigin parameter:

          public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false, $isSubQuery = false, Doctrine_Query $queryOrigin = null)
              if ($limit === false || !($limit > 0)) {
                  return $query;
              $orderby = stristr($query, 'ORDER BY');
              if ($offset !== false && $orderby === false) {
                  throw new Doctrine_Connection_Exception("OFFSET cannot be used in MSSQL without ORDER BY due to emulation reasons.");
              $count = intval($limit);
              $offset = intval($offset);
              if ($offset < 0) {
                  throw new Doctrine_Connection_Exception("LIMIT argument offset=$offset is not valid");
              $orderbySql = $queryOrigin->getSqlQueryPart('orderby');
              $orderbyDql = $queryOrigin->getDqlPart('orderby');
              if ($orderby !== false) {
                  $orders = $this->parseOrderBy(implode(', ', $queryOrigin->getDqlPart('orderby')));
                  for ($i = 0; $i < count($orders); $i++) {

      From just looking at the above code, the query chokes on the first call to a $queryOrigin method. It seems like there is a lot of missing code here which should work with the $query directly when $queryOrigin is not available...

      What is the point of $orderbySql and $orderbyDql variables when they are not used anywhere?

      This code looks like it's half way done and untested.


        There are no comments yet on this issue.


          • Assignee:
            Jonathan H. Wage
            Andrej Pavlovic
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: