Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.2.0-RC1
-
Fix Version/s: 1.2.2
-
Component/s: Connection
-
Labels:None
-
Environment:php 5.3.1,
Symfony 1.4.0-DEV
Doctrine 1.2.0-RC1
pdo_mssql (libdb)
Description
using a doctrine generated class's find method produced erroneous SQL such as:
SELECT TOP 1 [inner_tbl].[id] AS [b__id] FROM (SELECT TOP 1 [b].[id] AS [b__id], [b].[name] AS [b__name], [b].[alias] AS [b__alias], [b].[ip] AS [b__ip], [b].[operator_id] AS [b__operator_id], [b].[cell_id] AS [b__cell_id], [b].[latitude] AS [b__latitude], [b].[longtitude] AS [b__longtitude], [b].[community_read] AS [b__community_read], [b].[community_write] AS [b__community_write], [b].[last_found_at] AS [b__last_found_at], [b].[active] AS [b__active], [b].[type] AS [b__type], [b].[poll_mac_behind_sus] AS [b__poll_mac_behind_sus], [b].[created_at] AS [b__created_at] FROM [basestation] [b] WHERE ([b].[id] = '2')) AS [inner_tbl]
commenting out the following line (193) in' function modifyLimitQuery' for lib/Doctrine/Connection/Mssql.php
$query = preg_replace('/^'.$selectRegExp.'/i', $selectReplace . 'TOP ' . ($count + $offset) . ' ', $query);
//$query = 'SELECT TOP ' . $count . ' ' . $this->quoteIdentifier('inner_tbl') . '.' . $key_field . ' FROM (' . $query . ') AS ' . $this->quoteIdentifier('inner_tbl');
if ($orderby !== false) {
It appears to have worked. This method was part of jwage's commit for change set 6795 (http://trac.doctrine-project.org/changeset/6795/branches/1.2/lib/Doctrine/Connection/Mssql.php) so there must be a reason for this change. This is very preliminary. If the change works there is a considerable amount of refactoring that way be done. I will commit a proper patch once I am able to test exhaustively, at the moment this is a show stopper and I need to continue development.
Issue Links
- duplicates
-
DC-318
Doctrine_Table::find(x) fails for odbc/mssql connection due to limit() clause
-