From 61e55061a60b45736b778cf0334bde2664558233 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 29 Sep 2011 00:15:49 +0200 Subject: [PATCH] MDL-29566 mysql - length / decimal specs in float columns are optional --- lib/dml/mysqli_native_moodle_database.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 165adaeb16a..1bac5875360 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -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';