Skip to content
Browse files

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

  • Loading branch information...
1 parent 6272827 commit b558672db435f087c7872f85febe6a1656f80961 @stronk7 stronk7 committed
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/dml/mysqli_native_moodle_database.php
View
16 lib/dml/mysqli_native_moodle_database.php
@@ -489,7 +489,7 @@ public function get_columns($table, $usecache=true) {
$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 @@ public function get_columns($table, $usecache=true) {
$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';

0 comments on commit b558672

Please sign in to comment.
Something went wrong with that request. Please try again.