ZF-2417: Limit with Ordering broken

Description

A query which has a column named 'description' and is ordered by it 'description DESC' will be broken if limited.

The query is:


$columns = array('name', 'description');
$order = 'description DESC';
$select = new Zend_Db_Select($database);
$select->from('usertable', $columns);
$select->order($order);
$select->limitPage(1, 10);

$database->fetchAll($select);

Then I get an error... Looking into the created select statement I get:


SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 "description", "name" 
>FROM mytable ORDER BY "description" DESC ) AS inner_tbl ORDER BY "ription" 
ASC ) AS outer_tbl ORDER BY "ription" desc

This behaviour can be seen within MSSQL where no native limit exists. Possibly same problem when using any column name where "asc" is included.

Comments

Fixed within SVN-7399