From: stronk7 Date: Fri, 29 Sep 2006 23:10:31 +0000 (+0000) Subject: Added to more tests to check float <---> char conversion X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=cec4b7c621ab07e84da1665300cca6beb89c405e;p=moodle.git Added to more tests to check float <---> char conversion --- diff --git a/admin/xmldb/actions/test/test.class.php b/admin/xmldb/actions/test/test.class.php index 26e64b45ff..d6f97f607a 100644 --- a/admin/xmldb/actions/test/test.class.php +++ b/admin/xmldb/actions/test/test.class.php @@ -260,24 +260,50 @@ class test extends XMLDBAction { $tests['change field type (number2char)'] = $test; } - /// 11th test. Change the type of one column from varchar to number + /// 11th test. Change the type of one column from varchar to float if ($test->status) { /// Get SQL code and execute it $test = new stdClass; $field = new XMLDBField('grade'); - $field->setAttributes(XMLDB_TYPE_NUMBER, '20,10', XMLDB_UNSIGNED, null, null, null, null, null); + $field->setAttributes(XMLDB_TYPE_FLOAT, '20,10', XMLDB_UNSIGNED, null, null, null, null, null); $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true); $test->status = change_field_type($table, $field, false, false); if (!$test->status) { $test->error = $db->ErrorMsg(); } - $tests['change field type (char2number)'] = $test; + $tests['change field type (char2float)'] = $test; } - /// 12th test. Change the type of one column from text to binary + /// 12th test. Change the type of one column from float to char + if ($test->status) { + /// Get SQL code and execute it + $test = new stdClass; + $field = new XMLDBField('grade'); + $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'test'); + + $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true); + $test->status = change_field_type($table, $field, false, false); + if (!$test->status) { + $test->error = $db->ErrorMsg(); + } + $tests['change field type (float2char)'] = $test; + } - /// 13th test. Change the type of one column from binary to text + /// 13th test. Change the type of one column from char to number + if ($test->status) { + /// Get SQL code and execute it + $test = new stdClass; + $field = new XMLDBField('grade'); + $field->setAttributes(XMLDB_TYPE_NUMBER, '20,10', XMLDB_UNSIGNED, null, null, null, null, null); + + $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true); + $test->status = change_field_type($table, $field, false, false); + if (!$test->status) { + $test->error = $db->ErrorMsg(); + } + $tests['change field type (char2number)'] = $test; + } /// 14th test. Change the precision of one text field