Exception thrown when merging: 'Error reading from database"
bskamboj opened this issue · comments
Please have a look below error message and let know me what is the issue and solution:
Exception thrown when merging: 'Error reading from database".
Unknown column 'id' in 'field list'
Trace:
#0 /var/www/html/moodle/lib/dml/mysqli_native_moodle_database.php(1247): moodle_database->query_end(false)
#1 /var/www/html/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(297): mysqli_native_moodle_database->get_records_sql('SELECT id FROM ...')
#2 /var/www/html/moodle/admin/tool/mergeusers/lib/table/generictablemerger.php(73): GenericTableMerger->get_records_to_be_updated(Array, 'userid')
#3 /var/www/html/moodle/admin/tool/mergeusers/lib/mergeusertool.php(268): GenericTableMerger->merge(Array, Array, Array)
#4 /var/www/html/moodle/admin/tool/mergeusers/lib/mergeusertool.php(192): MergeUserTool->_merge('13630', '17840')
#5 /var/www/html/moodle/admin/tool/mergeusers/index.php(135): MergeUserTool->merge('13630', '17840')
#6 {main}
Thank you
Hi!
Thanks for reporting and detailing the error.
This kind of errors like Unknown column 'id' in 'field list'
is produced when there are custom tables in the Moodle database that do not contain the id
column.
Moodle forces by design that any table have to have an id
column.
Therefore, if that table does not contain any user information, you can skip merging that table. An easy solution would be adding a custom config in the file config/config.local.php
(create it if not exists, because it is not delivered with the plugin), and then put a content like this:
return array(
'exceptions' => array (
'your_table_name_with_no_id_column',
),
);
This content will be merged with the default config, and it will skip processing your table without id
column.
Your task is to identify the table that does not contain the id
column (it is no detailed in the stacktrace, unfortunately), and update the file config.local.php.
Give us feedback.
As always, try this in a testing environment first.
Regards,
Jordi
I'm closing this issue.
Hi @jpahullo, thought I might just post here since I experienced the exact same issue and resolved it (kind of with your fix).
I identified the table with no id
column and added it to the array but now when I attempted to merge I get the following
Exception - Call to a member function merge() on null
Progress, but not sure why it is null
EDIT
Actually looks like this for loop in lib.php doesn't like it...
foreach ($config->exceptions as $exception) {
$options[$exception] = $exception;
}
cause i get Warning: Invalid argument supplied for foreach() in
UPDATE
I carelessly forgot to put <?php
at top of my file... so now it is
<?php
return array(
'exceptions' => array (
'mdl_auth_wncon_extdata',
),
);
despite this it now shows the original error error reading from database...
Got it working after removing the mdl_
prefix on the table name :)
Good to know! yes, table names have to not have the table prefix ;-)