Merge branch 'MDL-29566_21' of git://github.com/stronk7/moodle into MOODLE_21_STABLE
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -727,6 +727,8 @@ class dml_test extends UnitTestCase {
|
||||
$table->add_field('description', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('enumfield', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, 'test2');
|
||||
$table->add_field('onenum', XMLDB_TYPE_NUMBER, '10,2', null, null, null, 200);
|
||||
$table->add_field('onefloat', XMLDB_TYPE_FLOAT, '10,2', null, null, null, 300);
|
||||
$table->add_field('anotherfloat', XMLDB_TYPE_FLOAT, null, null, null, null, 400);
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
@@ -771,10 +773,26 @@ class dml_test extends UnitTestCase {
|
||||
$field = $columns['onenum'];
|
||||
$this->assertEqual('N', $field->meta_type);
|
||||
$this->assertFalse($field->auto_increment);
|
||||
$this->assertEqual(10, $field->max_length);
|
||||
$this->assertEqual(2, $field->scale);
|
||||
$this->assertTrue($field->has_default);
|
||||
$this->assertEqual(200.0, $field->default_value);
|
||||
$this->assertFalse($field->not_null);
|
||||
|
||||
$field = $columns['onefloat'];
|
||||
$this->assertEqual('N', $field->meta_type);
|
||||
$this->assertFalse($field->auto_increment);
|
||||
$this->assertTrue($field->has_default);
|
||||
$this->assertEqual(300.0, $field->default_value);
|
||||
$this->assertFalse($field->not_null);
|
||||
|
||||
$field = $columns['anotherfloat'];
|
||||
$this->assertEqual('N', $field->meta_type);
|
||||
$this->assertFalse($field->auto_increment);
|
||||
$this->assertTrue($field->has_default);
|
||||
$this->assertEqual(400.0, $field->default_value);
|
||||
$this->assertFalse($field->not_null);
|
||||
|
||||
for ($i = 0; $i < count($columns); $i++) {
|
||||
if ($i == 0) {
|
||||
$next_column = reset($columns);
|
||||
|
||||
Reference in New Issue
Block a user