FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18855&edit=1

ID: 18855
Updated by: daniel.oconnor@gmail.com
Reported By: kouber at php dot net
Summary: Incorrect check for the last "ORDER BY" clause
Status: Open
Type: Bug
Package: Structures_DataGrid_DataSource_PDO
Operating System: Irrelevant
Package Version: 0.1.1dev1
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

Thanks for the patch Kouber


Previous Comments:
------------------------------------------------------------------------

[2011-09-21 00:17:59] kouber

Added #patch bug:18855;patch:DataSource.patch;revision:1316560679;.

------------------------------------------------------------------------

[2011-09-21 00:14:02] kouber

Description:
------------
Using PostgreSQL window functions (available since PostgreSQL 8.4)
breaks the general ORDER BY check, since there's an internal "window"
ORDER BY clause which comes even before the FROM clause of the query.

So, the query doesn't have an ORDER BY at the end, but such is detected
and it is omitted when composing the final query sent to the server,
hence the entire query breaks.

Test script:
---------------
$query = "SELECT
ROW_NUMBER() OVER (ORDER BY id) AS row_num,
id
FROM
xxx";

$this->bind($query, array('dbc' => Database::getInstance()));

Expected result:
----------------
Normal execution of the query, with a proper ORDER BY added at the end
with a column specified by setDefaultSort().

Actual result:
--------------
SQL error, since only a comma is added, instead of an entire ORDER BY.

A work-around is to add "ORDER BY TRUE" every time a window function is
used and no other ORDER BY is present.

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedSep 22, '11 at 10:51p
activeSep 22, '11 at 10:51p
posts1
users1
websitepear.php.net

1 user in discussion

Daniel Oconnor: 1 post

People

Translate

site design / logo © 2022 Grokbase