$tests['change field precision (number)'] = $test;
}
- /// 18th test. Change the sign of one numeric field to unsigned
+ /// 18th test. Change the precision of one integer field to a smaller one
+ if ($test->status) {
+ /// Get SQL code and execute it
+ $test = new stdClass;
+ $field = new XMLDBField('course');
+ $field->setAttributes(XMLDB_TYPE_INTEGER, '5', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+
+ $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
+ $test->status = change_field_precision($table, $field, false, false);
+ if (!$test->status) {
+ $test->error = $db->ErrorMsg();
+ }
+ $tests['change field precision (integer) to smaller one'] = $test;
+ }
+
+ /// 19th test. Change the sign of one numeric field to unsigned
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['change field sign (unsigned)'] = $test;
}
- /// 19th test. Change the sign of one numeric field to signed
+ /// 20th test. Change the sign of one numeric field to signed
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['change field sign (signed)'] = $test;
}
- /// 20th test. Change the nullability of one char field to not null
+ /// 21th test. Change the nullability of one char field to not null
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['change field nullability (not null)'] = $test;
}
- /// 21th test. Change the nullability of one char field to null
+ /// 22th test. Change the nullability of one char field to null
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['change field nullability (null)'] = $test;
}
- /// 22th test. Dropping the default of one field
+ /// 23th test. Dropping the default of one field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['drop field default of NULL field'] = $test;
}
- /// 23th test. Creating the default for one field
+ /// 24th test. Creating the default for one field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['add field default of NULL field'] = $test;
}
- /// 24th test. Creating the default for one field
+ /// 25th test. Creating the default for one field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
}
- /// 25th test. Dropping the default of one NOT NULL field
+ /// 26th test. Dropping the default of one NOT NULL field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['drop field default of NOT NULL field'] = $test;
}
- /// 26th test. Adding one unique index to the table
+ /// 27th test. Adding one unique index to the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['add unique index'] = $test;
}
- /// 27th test. Adding one not unique index to the table
+ /// 28th test. Adding one not unique index to the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['add not unique index'] = $test;
}
- /// 28th test. Re-add the same index than previous test. Check find_index_name() works.
+ /// 29th test. Re-add the same index than previous test. Check find_index_name() works.
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['check find_index_name()'] = $test;
}
- /// 29th test. Dropping one index from the table
+ /// 30th test. Dropping one index from the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['drop index'] = $test;
}
- /// 30th test. Adding one unique key to the table
+ /// 31th test. Adding one unique key to the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['add unique key'] = $test;
}
- /// 31th test. Adding one foreign+unique key to the table
+ /// 32th test. Adding one foreign+unique key to the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['add foreign+unique key'] = $test;
}
- /// 32th test. Drop one key
+ /// 33th test. Drop one key
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['drop foreign+unique key'] = $test;
}
- /// 33th test. Adding one foreign key to the table
+ /// 34th test. Adding one foreign key to the table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['add foreign key'] = $test;
}
- /// 34th test. Drop one foreign key
+ /// 35th test. Drop one foreign key
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['drop foreign key'] = $test;
}
- /// 35th test. Adding one complex enum field
+ /// 36th test. Adding one complex enum field
if ($test->status) {
/// Create a new field with complex specs (enums are good candidates)
$field = new XMLDBField('type');
$tests['add field with enum'] = $test;
}
- /// 36th test. Dropping the enum of one field
+ /// 37th test. Dropping the enum of one field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['delete enumlist from one field'] = $test;
}
- /// 37th test. Creating the enum for one field
+ /// 38th test. Creating the enum for one field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['add enumlist to one field'] = $test;
}
- /// 38th test. Renaming one index
+ /// 39th test. Renaming one index
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['rename index (experimental. DO NOT USE IT)'] = $test;
}
- /// 39th test. Renaming one key
+ /// 40th test. Renaming one key
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$tests['rename key (experimental. DO NOT USE IT)'] = $test;
}
- /// 40th test. Renaming one field
+ /// 41th test. Renaming one field
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
$field = new XMLDBField('type');
$field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course');
-
+
$test->sql = $table->getRenameFieldSQL($CFG->dbtype, $CFG->prefix, $field, 'newnameforthefield', true);
$test->status = rename_field($table, $field, 'newnameforthefield', false, false);
if (!$test->status) {
$tests['rename field'] = $test;
}
- /// 41th test. Renaming one table
+ /// 42th test. Renaming one table
if ($test->status) {
/// Get SQL code and execute it
$test = new stdClass;
-
+
$test->sql = $table->getRenameTableSQL($CFG->dbtype, $CFG->prefix, 'newnameforthetable', true);
$test->status = rename_table($table, 'newnameforthetable', false, false);
if (!$test->status) {
$tests['rename table'] = $test;
}
- /// 42th test. Getting the PK sequence name for one table
+ /// 43th test. Getting the PK sequence name for one table
if ($test->status) {
$test = new stdClass;
$table->setName('newnameforthetable');
$tests['find sequence name'] = $test;
}
- /// 43th test. Inserting TEXT contents
+ /// 44th test. Inserting TEXT contents
$textlib = textlib_get_instance();
if ($test->status) {
$test = new stdClass;
$tests['insert record '. $textlen . ' cc. (text)'] = $test;
}
- /// 44th test. Inserting BINARY contents
+ /// 45th test. Inserting BINARY contents
if ($test->status) {
$test = new stdClass;
$test->status = false;
$tests['insert record '. $textlen . ' bytes (binary)'] = $test;
}
- /// 45th test. update_record with TEXT and BINARY contents
+ /// 46th test. update_record with TEXT and BINARY contents
if ($test->status) {
$test = new stdClass;
$test->status = false;
$tests['update record '. $textlen . ' cc. (text) and ' . $imglen . ' bytes (binary)'] = $test;
}
- /// 46th test. set_field with TEXT contents
+ /// 47th test. set_field with TEXT contents
if ($test->status) {
$test = new stdClass;
$test->status = false;
$tests['set field '. $textlen . ' cc. (text)'] = $test;
}
- /// 47th test. set_field with BINARY contents
+ /// 48th test. set_field with BINARY contents
if ($test->status) {
$test = new stdClass;
$test->status = false;