Commit d64514aa authored by stronk7's avatar stronk7
Browse files

MDL-14679 - PG get_indexes() fix - minor problem retrieving indexes with columns quoted

parent 08f4df55
......@@ -290,7 +290,7 @@ class pgsql_native_moodle_database extends moodle_database {
continue;
}
$columns = explode(',', $matches[4]);
$columns = array_map('trim', $columns);
$columns = array_map(array($this, 'trim_quotes'), $columns);
$indexes[$matches[2]] = array('unique'=>!empty($matches[1]),
'columns'=>$columns);
}
......@@ -1155,4 +1155,16 @@ class pgsql_native_moodle_database extends moodle_database {
pg_free_result($result);
return true;
}
/**
* Helper function trimming (whitespace + quotes) any string
* needed because PG uses to enclose with double quotes some
* fields in indexes definition and others
*
* @param string $str string to apply whitespace + quotes trim
* @return string trimmed string
*/
private function trim_quotes($str) {
return trim(trim($str), "'\"");
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment