Error reading from database - Download in text format

Error reading from database - Download in text format

by Murilo Timo Neto -
Number of replies: 3

Hi

I have the following error when I try to download in text format

Error reading from database

with the debug on:

Error reading from database

More information about this error

Debug info: ERRO: tipos no UNION bigint e character varying não podem corresponder
LINE 44: qrb.choice_id, null AS response, 0 AS ran...
^

SELECT qr.id || '_' || 'radiobuttons' || '_' || qrs.id AS id,
qr.submitted, qr.complete, qr.grade, qr.username, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as userid, qr.id AS rid, qrs.question_id,
qrs.choice_id, qro.response, 0 AS rank
FROM mdl_questionnaire_response qr
JOIN mdl_questionnaire_resp_single qrs ON qrs.response_id = qr.id

AND qr.survey_id = $1 AND qr.complete = $2
LEFT JOIN mdl_questionnaire_response_other qro ON qro.response_id = qr.id AND qro.choice_id = qrs.choice_id
LEFT JOIN mdl_user u ON u.id = CAST(qr.username AS INT)
UNION ALL
SELECT qr.id || '_' || 'checkboxes' || '_' || qrm.id AS id,
qr.submitted, qr.complete, qr.grade, qr.username, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as userid, qr.id AS rid, qrm.question_id,
qrm.choice_id, qro.response, 0 AS rank
FROM mdl_questionnaire_response qr
JOIN mdl_questionnaire_resp_multiple qrm ON qrm.response_id = qr.id

AND qr.survey_id = $3 AND qr.complete = $4
LEFT JOIN mdl_questionnaire_response_other qro ON qro.response_id = qr.id AND qro.choice_id = qrm.choice_id
LEFT JOIN mdl_user u ON u.id = CAST(qr.username AS INT)
UNION ALL
SELECT qr.id || '_' || 'ratescale' || '_' || qrr.id AS id,
qr.submitted, qr.complete, qr.grade, qr.username, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as userid, qr.id AS rid, qrr.question_id,
qrr.choice_id, null AS response, qrr.rank
FROM mdl_questionnaire_response qr
JOIN mdl_questionnaire_response_rank qrr
ON qrr.response_id = qr.id

AND qr.survey_id = $5 AND qr.complete = $6
LEFT JOIN mdl_user u ON u.id = CAST(qr.username AS INT)
UNION ALL
SELECT qr.id || '_' || 'essaybox' || '_' || qrt.id AS id,
qr.submitted, qr.complete, qr.grade, qr.username, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as userid, qr.id AS rid, qrt.question_id,
0 AS choice_id, qrt.response, 0 AS rank
FROM mdl_questionnaire_response qr
JOIN mdl_questionnaire_response_text qrt
ON qrt.response_id = qr.id

AND qr.survey_id = $7 AND qr.complete = $8
LEFT JOIN mdl_user u ON u.id = CAST(qr.username AS INT)
UNION ALL
SELECT qr.id || '_' || 'yesno' || '_' || qrb.id AS id,
qr.submitted, qr.complete, qr.grade, qr.username, u.firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.firstname, u.lastname, u.username, u.department, u.institution, u.id as userid, qr.id AS rid, qrb.question_id,
qrb.choice_id, null AS response, 0 AS rank
FROM mdl_questionnaire_response qr
JOIN mdl_questionnaire_response_bool qrb
ON qrb.response_id = qr.id

AND qr.survey_id = $9 AND qr.complete = $10
LEFT JOIN mdl_user u ON u.id = CAST(qr.username AS INT)
ORDER BY userid, id
[array (
0 => '1',
1 => 'y',
2 => '1',
3 => 'y',
4 => '1',
5 => 'y',
6 => '1',
7 => 'y',
8 => '1',
9 => 'y',
)]
Error code: dmlreadexception
Stack trace:
  • line 474 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 244 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
  • line 753 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
  • line 2512 of /mod/questionnaire/questionnaire.class.php: call to pgsql_native_moodle_database->get_recordset_sql()
  • line 2697 of /mod/questionnaire/questionnaire.class.php: call to questionnaire->get_survey_all_responses()
  • line 490 of /mod/questionnaire/report.php: call to questionnaire->generate_csv()

i´m using

Moodle 3.1+ (Build: 20160526)

and questionnaire 3.1.0 (Build - 2016052000)

database is postgres,

i ´m begining whith moodle

I appreciate your help

Average of ratings: -
In reply to Murilo Timo Neto

Re: Error reading from database - Download in text format

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

It looks like something specific to Postgres...

I believe the problem is that the "choice_id" column is a character type for the boolean response table and an integer for all others. Postgres doesn't like that.

I have created issue CONTRIB-6436 for this bug.

mike

Average of ratings: Useful (1)
In reply to Murilo Timo Neto

Re: Error reading from database - Download in text format

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

This has been fixed with the details in CONTRIB-6436. For now, you can pull the latest from the MOODLE_31_STABLE branch, or apply the diff linked in the issue. When questionnaire release 3.1.2 comes out, the fix will be included.

mike

Average of ratings: Useful (1)