mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-27982 convert all signed to unsigned and prevent adding of new unsigned columns
Conflicts, amended to use .02 versions: lib/db/upgrade.php, version.php
This commit is contained in:
parent
7e522ccbc8
commit
e9e4a4a672
@ -196,6 +196,15 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2012030100.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2012030100.02) {
|
||||
// migrate all numbers to signed - it should be safe to interrupt this and continue later
|
||||
upgrade_mysql_fix_unsigned_columns();
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2012030100.02);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -659,12 +659,13 @@ class database_manager {
|
||||
/**
|
||||
* This function will change the unsigned/signed of the field in the table passed as arguments
|
||||
*
|
||||
* @deprecated since 2.3, only singed numbers are allowed now, migration is automatic
|
||||
* @param xmldb_table $xmldb_table Table object (just the name is mandatory).
|
||||
* @param xmldb_field $xmldb_field Field object (full specs are required).
|
||||
* @return void
|
||||
*/
|
||||
public function change_field_unsigned(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
|
||||
/// Just a wrapper over change_field_type. Does exactly the same processing
|
||||
debugging('All unsigned numbers are converted to signed automatically during Moodle upgrade.');
|
||||
$this->change_field_type($xmldb_table, $xmldb_field);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,6 @@ class mssql_sql_generator extends sql_generator {
|
||||
|
||||
public $number_type = 'DECIMAL'; // Proper type for NUMBER(x) in this DB
|
||||
|
||||
public $unsigned_allowed = false; // To define in the generator must handle unsigned information
|
||||
public $default_for_char = ''; // To define the default to set for NOT NULLs CHARs without default (null=do nothing)
|
||||
|
||||
public $specify_nulls = true; //To force the generator if NULL clauses must be specified. It shouldn't be necessary
|
||||
|
@ -43,7 +43,6 @@ class oracle_sql_generator extends sql_generator {
|
||||
|
||||
public $number_type = 'NUMBER'; // Proper type for NUMBER(x) in this DB
|
||||
|
||||
public $unsigned_allowed = false; // To define in the generator must handle unsigned information
|
||||
public $default_for_char = ' '; // To define the default to set for NOT NULLs CHARs without default (null=do nothing)
|
||||
// Using this whitespace here because Oracle doesn't distinguish empty and null! :-(
|
||||
|
||||
|
@ -40,7 +40,6 @@ class postgres_sql_generator extends sql_generator {
|
||||
|
||||
public $number_type = 'NUMERIC'; // Proper type for NUMBER(x) in this DB
|
||||
|
||||
public $unsigned_allowed = false; // To define in the generator must handle unsigned information
|
||||
public $default_for_char = ''; // To define the default to set for NOT NULLs CHARs without default (null=do nothing)
|
||||
|
||||
public $sequence_extra_code = false; //Does the generator need to add extra code to generate the sequence fields
|
||||
|
@ -901,20 +901,6 @@ class ddl_test extends UnitTestCase {
|
||||
//TODO: check the rest of attributes
|
||||
}
|
||||
|
||||
public function testChangeFieldSign() {
|
||||
$dbman = $this->tdb->get_manager();
|
||||
// TODO: verify the signed is changed in db
|
||||
|
||||
$table = $this->create_deftable('test_table1');
|
||||
$field = new xmldb_field('grade');
|
||||
$field->set_attributes(XMLDB_TYPE_NUMBER, '10,2', XMLDB_UNSIGNED, null, null, null);
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
|
||||
$field = new xmldb_field('grade');
|
||||
$field->set_attributes(XMLDB_TYPE_NUMBER, '10,2', null, null, null, null);
|
||||
$dbman->change_field_unsigned($table, $field);
|
||||
}
|
||||
|
||||
public function testChangeFieldNullability() {
|
||||
$DB = $this->tdb; // do not use global $DB!
|
||||
$dbman = $this->tdb->get_manager();
|
||||
|
@ -65,8 +65,6 @@ abstract class sql_generator {
|
||||
/** @var string Proper type for NUMBER(x) in this DB. */
|
||||
public $number_type = 'NUMERIC';
|
||||
|
||||
/** @var bool To define in the generator must handle unsigned information.*/
|
||||
public $unsigned_allowed = true;
|
||||
/** @var string To define the default to set for NOT NULLs CHARs without default (null=do nothing).*/
|
||||
public $default_for_char = null;
|
||||
|
||||
@ -489,14 +487,7 @@ abstract class sql_generator {
|
||||
/// The type and length
|
||||
$field .= ' ' . $this->getTypeSQL($xmldb_field->getType(), $xmldb_field->getLength(), $xmldb_field->getDecimals());
|
||||
}
|
||||
/// The unsigned if supported
|
||||
if ($this->unsigned_allowed && ($xmldb_field->getType() == XMLDB_TYPE_INTEGER ||
|
||||
$xmldb_field->getType() == XMLDB_TYPE_NUMBER ||
|
||||
$xmldb_field->getType() == XMLDB_TYPE_FLOAT)) {
|
||||
if ($xmldb_field->getUnsigned()) {
|
||||
$field .= ' unsigned';
|
||||
}
|
||||
}
|
||||
/// note: unsigned is not supported any more since moodle 2.3, all numbers are signed
|
||||
/// Calculate the not null clause
|
||||
$notnull = '';
|
||||
/// Only if we don't want to skip it
|
||||
|
@ -53,7 +53,6 @@ class sqlite_sql_generator extends sql_generator {
|
||||
public $sequence_only = true; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name publiciable
|
||||
public $sequence_extra_code = false; //Does the generator need to add extra code to generate the sequence fields
|
||||
public $sequence_name = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'; //Particular name for inline sequences in this generator
|
||||
public $unsigned_allowed = false; // To define in the generator must handle unsigned information
|
||||
|
||||
public $enum_inline_code = true; //Does the generator need to add inline code in the column definition
|
||||
public $enum_extra_code = false; //Does the generator need to add extra code to generate code for the enums in the table
|
||||
|
@ -30,7 +30,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2012030100.01; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2012030100.02; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user