Skip to content

Commit

Permalink
MDL-59583 dml: fixed breaking change added w/ MariaDB 10.2.7+
Browse files Browse the repository at this point in the history
  • Loading branch information
scara committed Jul 25, 2017
1 parent dae6c5d commit 0510d5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/dml/mariadb_native_moodle_database.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public function get_server_info() {
return array('description'=>$this->mysqli->server_info, 'version'=>$version);
}

protected function has_breaking_change_quoted_defaults() {
$version = $this->get_server_info()['version'];
// Breaking change since 10.2.7: MDEV-13132.
return version_compare($version, '10.2.7', '>=');
}

/**
* It is time to require transactions everywhere.
*
Expand Down
14 changes: 13 additions & 1 deletion lib/dml/mysqli_native_moodle_database.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,14 @@ public function get_columns($table, $usecache=true) {
return $structure;
}

/**
* Indicates whether column information retrieved from `information_schema.columns` has default values quoted or not.
* @return boolean True when default values are quoted (breaking change); otherwise, false.
*/
protected function has_breaking_change_quoted_defaults() {
return false;
}

/**
* Returns moodle column info for raw column from information schema.
* @param stdClass $rawcolumn
Expand All @@ -794,7 +802,11 @@ private function get_column_info(stdClass $rawcolumn) {
$info->name = $rawcolumn->column_name;
$info->type = $rawcolumn->data_type;
$info->meta_type = $this->mysqltype2moodletype($rawcolumn->data_type);
$info->default_value = $rawcolumn->column_default;
if ($this->has_breaking_change_quoted_defaults()) {
$info->default_value = trim($rawcolumn->column_default, "'");
} else {
$info->default_value = $rawcolumn->column_default;
}
$info->has_default = !is_null($rawcolumn->column_default);
$info->not_null = ($rawcolumn->is_nullable === 'NO');
$info->primary_key = ($rawcolumn->column_key === 'PRI');
Expand Down

0 comments on commit 0510d5c

Please sign in to comment.