I'm running PostgreSQL 8.3.7 as my back-end database and it's very particular about query syntax. When I try to create a Book page, I get the following error:
warning: pg_query() [function.pg-query]: Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list in /opt/www/drupal-6.12/includes/database.pgsql.inc on line 139.
user warning: query: SELECT DISTINCT g.gid FROM simple_access_groups g INNER JOIN simple_access_roles r ON g.gid = r.gid WHERE r.rid IN (2) ORDER BY weight, name in /opt/www/drupal-sites/all/modules/simple_access/simple_access.module on line 597.
In simple_access_group_select, you need to add g.gid to the ORDER BY and weight and to the SELECT list. So, line 597 should read:
$result = db_query('SELECT DISTINCT ON (g.gid) g.gid, weight, name FROM {simple_access_groups} g INNER JOIN {simple_access_roles} r ON g.gid = r.gid WHERE r.rid IN ('. implode(',', array_fill(0, count($roles), '%d')) .') ORDER BY g.gid, weight, name', $roles);
Comments
Comment #1
alpapan commentedverifying and subscribing
also at
/admin/content/simple_access
Comment #2
gordon commentedI have made a fix to the select, I am not sure it it will work, but if you can give it a go. I couldn't use the select above as it would stuff up the weights.
Comment #3
gordon commentedI have install postgresql and the dev version should be working, Can you please give it a test and make sure.
Comment #5
Anonymous (not verified) commentedI tried the rc4 and the dev version. The problem is not fixed. When I trie to alter a node protected with simple access, I get this message:
Comment #6
Anonymous (not verified) commentedHi gordon. Based on this article from Jeff's SQL Server Blog I found a solution.
SELECT g.gid FROM {simple_access_groups} g INNER JOIN {simple_access_roles} r ON g.gid = r.gid WHERE r.rid IN ('. implode(',', array_fill(0, count($roles), '%d')) .') GROUP BY g.gid,g.name ORDER BY max(g.weight), g.namePlease make sure that the 'weight' still works, as you intended.
Comment #7
gordon commentedI have looked at this again, and made some changes to the dev version.
Give it ago and I will see what difference it makes.
Gordon.
Comment #8
Anonymous (not verified) commentedIt works!
Comment #9
Anonymous (not verified) commentedSorry to bother you again gorden, but I found an other simular mistake.
Comment #10
Anonymous (not verified) commentedThe problem is based on these three lines of SQL:
in simple_access.admin.inc on line 261
in simple_access.admin.inc on line 266
in simple_access.admin.inc on line 272
The "ORDER BY" is added by the tablesort_sql function in simple_access.admin.inc on line 280.
When you use the "GROUP BY" clause, in the pager_query function in line 281, you have to pass a query that will be used to count the records.
Is DISTINCT necessary? I removed it and had no duplicates.
Comment #11
alpapan commentedjust to verify that CvJ's fix works for problem @ /admin/content/simple_access
Comment #12
gordon commentedI have fixed this issue by actually removing this functionality which is now covered by the devel node access module.