Hello! I'm using Workspace 1.13, on MacOS X, with MySQL 4.0.15. I encountered some problems.

1) Whenever I try to sort attached files by size, I get this error:

user error: Unknown column 'size' in 'order clause'
query: SELECT n.nid, f.filemime, f.filename, f.filesize FROM files f, node n WHERE n.uid = 1 AND n.nid = f.nid ORDER BY  size ASC LIMIT 0, 50 in /Library/WebServer/Documents/drupal/includes/database.mysql.inc on line 66.

I'm not really MySQL-wise, so I have no idea why it does that, or how to fix it.

2) The pager that shows at the bottom of the files isn't the pager of the files, but the previous pager, the one attached to the nodes.

I managed to fix this by replacing the current line 268:
$pager = theme('pager', NULL, $maxfilenames, 0, tablesort_pager());
with this line:
$pager = theme('pager', NULL, $maxfilenames, 1, tablesort_pager());

What this does is keeping id '0' for the first pager (the node one), but giving id '1' to the second pager(the files one), so that they can both show up correctly, being recognized by Drupal as different.

3) The node pager doesn't stretch properly till the end of the table, but gets cropped at column 5. Since there are currently 8 columns in the workspace node table, I fixed this by replacing the current line 244:
$rows[] = array(array('data' => $pager, 'colspan' => 5));
with:
$rows[] = array(array('data' => $pager, 'colspan' => 8));

The fixes are in the attached patch.

CommentFileSizeAuthor
workflow.patch1007 bytesAnonymous (not verified)

Comments

jnt’s picture

Hi, the error is pretty self descriptive. "...ORDER BY size ASC..." is having a problem and looking at the databases I can't see a 'size' field at all. I would guess that it is meant to be 'filesize'. Therefore try changeing the substring 'size' in the SQL query you gave to: 'f.filesize' . The 'f' prefix is simply the alias for the database 'files' as designated in the sub-clause '...FROM files f... '

My suggested corrected query would therefore read:

SELECT n.nid, f.filemime, f.filename, f.filesize FROM files f, node n WHERE n.uid = 1 AND n.nid = f.nid ORDER BY f.filesize ASC LIMIT 0, 50

Please follow up if this helps or not.

jvandyk’s picture

Both fixes are committed. Thanks.

Regarding the size bug, it looks like the tablesort code is not using SQL prefixes correctly (it should be sorting by f.size).

jvandyk’s picture

Assigned: Unassigned » jvandyk

Fixed.

moshe weitzman’s picture

you should explicitly pass in the prefix when you define your $header. Specify 'sort' => f.size and then tablesort will dothe right thing.

Anonymous’s picture

:) It works properly now! Thank you!

Anonymous’s picture