FAQ
Edit report at https://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
+Status: Closed
Type: Bug
Package: Structures_DataGrid_DataSource_PDO
Operating System: Irrelevant
Package Version: 0.1.1dev1
PHP Version: Irrelevant
-Assigned To:
+Assigned To: doconnor
Roadmap Versions:
New Comment:

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: doconnor
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.




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

[2011-09-23 00:52:29] doconnor

Thanks for the patch Kouber

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

[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
postedDec 27, '11 at 5:30a
activeDec 27, '11 at 5:30a
posts1
users1
websitepear.php.net

1 user in discussion

Daniel Oconnor: 1 post

People

Translate

site design / logo © 2022 Grokbase