PDOException : SQLSTATE[42883]: Undefined function: 7 ERREUR: la fonction rand() n'existe pas LINE 8: ORDER BY RAND() LIMIT 10 OFFSET 0 ^ HINT: Aucune fonction ne correspond au nom donné et aux types d'arguments. Vous devez ajouter des conversions explicites de type.: SELECT child_nid as nid, child_vid as vid, n.type FROM {quiz_node_relationship} qnr JOIN {node} n on qnr.child_nid = n.nid WHERE qnr.parent_vid = :parent_vid AND qnr.parent_nid = :parent_nid AND qnr.question_status = :question_status AND n.status = 1 ORDER BY RAND() LIMIT 10 OFFSET 0; Array ( [:parent_vid] => 223 [:parent_nid] => 142 [:question_status] => 0 ) dans _quiz_get_random_questions() (ligne 2818 dans \sites\all\modules\contrib\quiz\quiz.module).
I had to update with ORDER BY RANDOM() to work.
Comment | File | Size | Author |
---|---|---|---|
#6 | test.patch | 812 bytes | Da_Cloud |
#3 | quiz-fix_random_sort_on_postgresql-2853085-3.patch | 1.57 KB | Da_Cloud |
Comments
Comment #2
saturnino CreditAttribution: saturnino commentedComment #3
Da_Cloud CreditAttribution: Da_Cloud at INDICIA commentedAfter a quick search it seems we use the "ORDER BY RAND()" statement twice. Both in quiz.module more precise in the function _quiz_get_random_questions on line 2811 and in _quiz_get_random_taxonomy_question_ids on line 2864. With the second being marked for deletion in issue #2834587: D6 leftover undefined function db_fetch_array().
As for the fix simply changing the line to "ORDER BY RANDOM()" would indeed solve the issue for postgreSQL, but would instead crash any MySQL database. So instead I propose we simply change the current database query to an db_select, which should provide support for both database engines.
Old query
New query
Comment #4
Da_Cloud CreditAttribution: Da_Cloud at INDICIA commentedLooking at the testcases the issue in question passed the testscripts, but we're encountering 3 other issues when testing on PostgreSQL.
- The first 2 issues seems to be isolated in the upgrade path from 4.x to 5.x.
- The last issue seems to come from the function _quiz_active_result_id() (line 2653) in quiz.module, not sure however what is happening here.
Both seem to be isolated issues that should be handled in a new issue.
Since it seems the test haven't been run against PostgreSQL for some time I've uploaded an empty patch so we can compare the results.
Comment #5
Da_Cloud CreditAttribution: Da_Cloud at INDICIA commentedComment #6
Da_Cloud CreditAttribution: Da_Cloud at INDICIA commented