Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.2.2dev1

Bug #15879 error sort with databasename attached.
Submitted: 2009-02-04 13:46 UTC
From: rud5gtriplevision Assigned:
Status: Feedback Package: Structures_DataGrid_DataSource_DataObject
PHP Version: 5.2.5 OS: debian
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 33 - 21 = ?

 
 [2009-02-04 13:46 UTC] rud5gtriplevision (Rudger Gravestein)
Description: ------------ when sorting through setDefaultSort, i need to add the database name, because i use a join with two tables with an ambiguous field: updated_ts (on which i want to sort). result is (part of the SQL): ...ORDER BY `tablename.updated_ts` DESC; this gives a SQL error: "DB Error: no such field" [nativecode=1054 ** Unknown column 'tablename.updated_ts' in 'order clause'] this is because, in the file: /pear/Structures/DataGrid/DataSource/DataObject.php quoteIdentifier is used on the entire field, which in this case also contains the tablename. i have an patch, which i will upload to this report. (the patch is only used in the case of passing the sort variables as an array, so check it.) Test script: --------------- $do = DB_DataObject::factory ('tablename'); $jt = DB_DataObject::factory ('jointable'); $do->joinAdd ($jt); $dg =& new Structures_DataGrid (); $dg->setDefaultSort (array ('tablename.updated_ts' => 'DESC')); Expected result: ---------------- the expected result is (part of the SQL): ...ORDER BY `databasename`.`updated_ts` DESC; Actual result: -------------- the actual result is (part of the SQL): ...ORDER BY `databasename.updated_ts` DESC;

Comments

 [2009-02-04 14:01 UTC] rud5gtriplevision (Rudger Gravestein)
--- DataObject.php 2009-02-03 16:22:00.000000000 +0100 +++ 20090203_DataObject.php 2009-02-03 16:21:07.000000000 +0100 @@ -474,15 +474,7 @@ if (is_array($sortSpec)) { foreach ($sortSpec as $field => $direction) { $field = $this->_convertLinkKey($field); - if (strpos ($field, '.') !== false) { - $field = explode ('.', $field); - foreach ($field as $i => $f) { - $field[$i] = $db->quoteIdentifier ($f); - } - $field = implode ('.', $field); - } else { - $field = $db->quoteIdentifier($field); - } + $field = $db->quoteIdentifier($field); $this->_dataobject->orderBy("$field $direction"); } } else {
 [2009-02-04 14:01 UTC] rud5gtriplevision (Rudger Gravestein)
i couldn't upload a patch (error: should be a text file) so i attached it as a comment. kind regards, Rudger Gravestein
 [2011-12-27 11:40 UTC] doconnor (Daniel O'Connor)
The text leading up to this was: -------------------------- |--- DataObject.php 2009-02-03 16:22:00.000000000 +0100 |+++ 20090203_DataObject.php 2009-02-03 16:21:07.000000000 +0100 -------------------------- File to patch: DataObject.php patching file DataObject.php Hunk #1 FAILED at 474. 1 out of 1 hunk FAILED -- saving rejects to file DataObject.php.rej
 [2011-12-27 11:42 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Feedback
Thank you for taking the time to report a problem with the package. This problem may have been already fixed by a previous change that is in the SVN of the package. Please checking out the SVN repository of this package and upgrade svn checkout svn.php.net/repository/pear/packages/Structures_DataGrid_DataSource_DataObject/trunk pear upgrade package2.xml or pear upgrade package.xml If you are able to reproduce the bug with the latest SVN, please change the status back to "Open". Again, thank you for your continued support of PEAR. Either your patch is backwards or it's already fixed in git.