Since the orderby fix for postgre the rand() feature is broken (with mysql)
This caused the problem:
http://drupal.org/node/91665
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/views/views_q...
Presumable the same bug is in the 5.x branch.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | views_query.inc | 21.27 KB | strooltz |
| #7 | views_order2.patch.txt | 689 bytes | fago |
| #5 | views_orderby.patch.txt | 593 bytes | fago |
| #1 | view_order.diff.txt | 617 bytes | gordon |
Comments
Comment #1
gordon commentedI have applied this fix to my sites, and it seems to be working.
However I do not know it this will break pgsql again.
Comment #2
sammys commentedTested this on PostgreSQL in 4.7 and all is good. RTBC as far as PostgreSQL is concerned.
--
Sammy Spets
Synerger
http://synerger.com
Comment #3
thsutton commentedI've applied this patch and its working fine with PostgreSQL 8.1.4 and Drupal 5.0 beta 2. The only thing that tripped me up was forgetting to edit and re-save the view using random to get it to re-generate the query sans '()'.
Comment #4
merlinofchaos commentedI applied what I think is a better patch. I believe this works in all circumstances, but time will tell! Anyone using PGSQL, I invite you to try out HEAD and see if it works.
Comment #5
fagoI've just updated to the latest to the latest 4.7 version and unfortunately the rand() feature is still broken for mysql, because there is an extra point in the query..
ORDER BY .rand()a fix is attached, which only includes the point if there is something in front of..
Comment #6
merlinofchaos commentedOk the proper fix should be backported from 5 in the 4.7.x-1.x-dev branch.
Comment #7
fagoI'm afraid, it still doesn't work. (tested with 4.7 and mysql)
1. it doesn't insert the rand() in the order by, because there is no alias.
2. it added an invalid select for the rand() statement, I changed it to only add a field if it has a table.
fix for 4.7 attached, hopefully it's still working with postgresql, however I think so as I've made no changes for usual add_orderby() calls.
Comment #8
merlinofchaos commentedArgh I left out the bit that gives the random sort an alias. Sigh.
Since this has only been 3 hours I redid the release to include the missing alias. (It's been in the drupal 5 version for days but I'm apparently getting worse and worse with branch management =)
If you downloaded Views 4.7.x-1.2 between 10am and 1pm pacific time today, download it again.
Comment #9
fagoyep, seems to work now.
thanks!
Comment #10
strooltz commentedI'm still having this problem. I patched my views_query.inc and couldn't get it to work...
this is the error:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid WHE' at line 1 query: SELECT node.nid, rand() AS _rand() FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid WHERE (node.status = '1') AND (node.type IN ('image')) AND (term_node.tid IN ('8')) ORDER BY _rand() ASC LIMIT 0, 1 in
I've also attached the views_query.inc im using...
thanks
s
Comment #11
dkashen commentedHello,
I'm transferring a drupal SQL database between two different hosts (and
hosting companies) via a backup and restore sequence.
The old host WB-hosting runs MySQL version 5.0.24-standard
while the KB says that site5.com runs sql v 4.1.21
and I'm getting an error I believe relates to the different SQL versions,
but it gives an error that is similar to one cited in this thread.
Let me know if there is any more info that would be useful.
Thank you,
Comment #12
(not verified) commentedComment #13
Bèr Kessels commentedaccording to last two reports not fixed.
Here is my query output, using "views_query.inc,v 1.48.2.12 2007/01/16 04:21:55"
SELECT node.nid, rand(), node.title AS node_title, node.changed AS node_changed, node_data_field_salary_sought.field_salary_sought_value AS node_data_field_salary_sought_field_salary_sought_value, node_data_field_current_location.field_current_location_value AS node_data_field_current_location_field_current_location_value FROM node node LEFT JOIN node_data_field_salary_sought node_data_field_salary_sought ON node.vid = node_data_field_salary_sought.vid LEFT JOIN node_data_field_current_location node_data_field_current_location ON node.vid = node_data_field_current_location.vid WHERE (node.status = '1') AND (node.type IN ('content_job_listing_entry')) ORDER BY ASC LIMIT 0, 5Comment #14
Bèr Kessels commentedFiddling a bit with the views solved the weird bug. I removed and added the view entirely. Seems some combination of a broken view and a stale cache.
Can strooltz and dkashen please confirm that removing + re-adding the view solves their Database error too?
setting this to 'needs more info'
Comment #15
merlinofchaos commentedI was going to ask if you had resaved the view; the view you exported is cachable, and Views currently caches the query on the view. (Yes, this has been creating alarming side effects, but I was concerned about caching it in the cache tables. Clearly I should have, and in the future I will.
Comment #16
Bèr Kessels commentedmerely re-saving did not help. I really had to remove the old one entirely and add a new one (by hand).
Comment #17
catch