MDL-29566 mysql - length / decimal specs in float columns are optional

This commit is contained in:
Eloy Lafuente (stronk7) 2011-09-29 00:15:49 +02:00
parent 12e89a0a69
commit 61e55061a6

View File

@ -489,7 +489,7 @@ class mysqli_native_moodle_database extends moodle_database {
$info->unique = null;
}
} else if (preg_match('/(decimal|double|float)\((\d+),(\d+)\)/i', $rawcolumn->type, $matches)) {
} else if (preg_match('/(decimal)\((\d+),(\d+)\)/i', $rawcolumn->type, $matches)) {
$info->type = $matches[1];
$info->meta_type = 'N';
$info->max_length = $matches[2];
@ -503,6 +503,20 @@ class mysqli_native_moodle_database extends moodle_database {
$info->auto_increment= false;
$info->unique = null;
} else if (preg_match('/(double|float)(\((\d+),(\d+)\))?/i', $rawcolumn->type, $matches)) {
$info->type = $matches[1];
$info->meta_type = 'N';
$info->max_length = isset($matches[3]) ? $matches[3] : null;
$info->scale = isset($matches[4]) ? $matches[4] : null;
$info->not_null = ($rawcolumn->null === 'NO');
$info->default_value = $rawcolumn->default;
$info->has_default = is_null($info->default_value) ? false : true;
$info->primary_key = ($rawcolumn->key === 'PRI');
$info->binary = false;
$info->unsigned = (stripos($rawcolumn->type, 'unsigned') !== false);
$info->auto_increment= false;
$info->unique = null;
} else if (preg_match('/([a-z]*text)/i', $rawcolumn->type, $matches)) {
$info->type = $matches[1];
$info->meta_type = 'X';