Doctrine 1
  1. Doctrine 1
  2. DC-978

Doctrine_Connection_Mssql dies on modifyLimitSubquery every time

    Details

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

      Description

      Looking at the latest version of Doctrine_Connection_Mssql in git repo:
      https://github.com/doctrine/doctrine1/blob/b4dc8e66a89a7e17cd195c489b18005e19ca9ea5/lib/Doctrine/Connection/Mssql.php

      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.

        Activity

          People

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

            Dates

            • Created:
              Updated: