mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-31985 remove LOB sizes from code and UI
This commit is contained in:
parent
05aae0a571
commit
f13489df50
@ -75,20 +75,24 @@ function transformForm(event) {
|
||||
switch (typeField.value) {
|
||||
case '1': // XMLDB_TYPE_INTEGER
|
||||
lengthTip.innerHTML = ' 1...20';
|
||||
lengthField.disabled = false;
|
||||
decimalsTip.innerHTML = '';
|
||||
decimalsField.disabled = true;
|
||||
decimalsField.value = '';
|
||||
break;
|
||||
case '2': // XMLDB_TYPE_NUMBER
|
||||
lengthTip.innerHTML = ' 1...20';
|
||||
lengthField.disabled = false;
|
||||
decimalsTip.innerHTML = ' 0...length or empty';
|
||||
break;
|
||||
case '3': // XMLDB_TYPE_FLOAT
|
||||
lengthTip.innerHTML = ' 1...20 or empty';
|
||||
lengthField.disabled = false;
|
||||
decimalsTip.innerHTML = ' 0...length or empty';
|
||||
break;
|
||||
case '4': // XMLDB_TYPE_CHAR
|
||||
lengthTip.innerHTML = ' 1...1333'; // Hardcoded, yes!
|
||||
lengthField.disabled = false;
|
||||
decimalsTip.innerHTML = '';
|
||||
decimalsField.disabled = true;
|
||||
decimalsField.value = '';
|
||||
@ -96,7 +100,8 @@ function transformForm(event) {
|
||||
sequenceField.value = '0';
|
||||
break;
|
||||
case '5': // XMLDB_TYPE_TEXT
|
||||
lengthTip.innerHTML = ' small, medium, big';
|
||||
lengthTip.innerHTML = '';
|
||||
lengthField.disabled = true;
|
||||
decimalsTip.innerHTML = '';
|
||||
decimalsField.disabled = true;
|
||||
decimalsField.value = '';
|
||||
@ -106,7 +111,8 @@ function transformForm(event) {
|
||||
defaultField.value = '';
|
||||
break;
|
||||
case '6': // XMLDB_TYPE_BINARY
|
||||
lengthTip.innerHTML = ' small, medium, big';
|
||||
lengthTip.innerHTML = '';
|
||||
lengthField.disabled = true;
|
||||
decimalsTip.innerHTML = '';
|
||||
decimalsField.disabled = true;
|
||||
decimalsField.value = '';
|
||||
|
@ -49,8 +49,6 @@ class edit_field_save extends XMLDBAction {
|
||||
'numberincorrectlength' => 'tool_xmldb',
|
||||
'floatincorrectlength' => 'tool_xmldb',
|
||||
'charincorrectlength' => 'tool_xmldb',
|
||||
'textincorrectlength' => 'tool_xmldb',
|
||||
'binaryincorrectlength' => 'tool_xmldb',
|
||||
'numberincorrectdecimals' => 'tool_xmldb',
|
||||
'floatincorrectdecimals' => 'tool_xmldb',
|
||||
'defaultincorrect' => 'tool_xmldb',
|
||||
@ -201,28 +199,8 @@ class edit_field_save extends XMLDBAction {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Text checks
|
||||
if ($type == XMLDB_TYPE_TEXT) {
|
||||
if ($length != 'small' &&
|
||||
$length != 'medium' &&
|
||||
$length != 'big') {
|
||||
$errors[] = $this->str['textincorrectlength'];
|
||||
}
|
||||
if ($default !== NULL && $default !== '') {
|
||||
if (substr($default, 0, 1) == "'" ||
|
||||
substr($default, -1, 1) == "'") {
|
||||
$errors[] = $this->str['defaultincorrect'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Binary checks
|
||||
if ($type == XMLDB_TYPE_BINARY) {
|
||||
if ($length != 'small' &&
|
||||
$length != 'medium' &&
|
||||
$length != 'big') {
|
||||
$errors[] = $this->str['binaryincorrectlength'];
|
||||
}
|
||||
}
|
||||
// No text checks
|
||||
// No binary checks
|
||||
|
||||
if (!empty($errors)) {
|
||||
$tempfield = new xmldb_field($name);
|
||||
|
@ -27,7 +27,6 @@ $string['actual'] = 'Actual';
|
||||
$string['aftertable'] = 'After table:';
|
||||
$string['back'] = 'Back';
|
||||
$string['backtomainview'] = 'Back to main';
|
||||
$string['binaryincorrectlength'] = 'Incorrect length for binary field';
|
||||
$string['cannotuseidfield'] = 'Cannot insert the "id" field. It is an autonumeric column';
|
||||
$string['completelogbelow'] = '(see the complete log of the search below)';
|
||||
$string['confirmdeletefield'] = 'Are you absolutely sure that you want to delete the field:';
|
||||
@ -159,7 +158,6 @@ $string['selecttable'] = 'Select table:';
|
||||
$string['table'] = 'Table';
|
||||
$string['tablenameempty'] = 'The table name cannot be empty';
|
||||
$string['tables'] = 'Tables';
|
||||
$string['textincorrectlength'] = 'Incorrect length for text field';
|
||||
$string['unload'] = 'Unload';
|
||||
$string['up'] = 'Up';
|
||||
$string['view'] = 'View';
|
||||
|
@ -202,28 +202,10 @@ class mysql_sql_generator extends sql_generator {
|
||||
$dbtype .= '(' . $xmldb_length . ')';
|
||||
break;
|
||||
case XMLDB_TYPE_TEXT:
|
||||
if (empty($xmldb_length)) {
|
||||
$xmldb_length = 'small';
|
||||
}
|
||||
if ($xmldb_length == 'small') {
|
||||
$dbtype = 'TEXT';
|
||||
} else if ($xmldb_length == 'medium') {
|
||||
$dbtype = 'MEDIUMTEXT';
|
||||
} else {
|
||||
$dbtype = 'LONGTEXT';
|
||||
}
|
||||
$dbtype = 'LONGTEXT';
|
||||
break;
|
||||
case XMLDB_TYPE_BINARY:
|
||||
if (empty($xmldb_length)) {
|
||||
$xmldb_length = 'small';
|
||||
}
|
||||
if ($xmldb_length == 'small') {
|
||||
$dbtype = 'BLOB';
|
||||
} else if ($xmldb_length == 'medium') {
|
||||
$dbtype = 'MEDIUMBLOB';
|
||||
} else {
|
||||
$dbtype = 'LONGBLOB';
|
||||
}
|
||||
$dbtype = 'LONGBLOB';
|
||||
break;
|
||||
case XMLDB_TYPE_DATETIME:
|
||||
$dbtype = 'DATETIME';
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
<xs:simpleType name="fieldLength" >
|
||||
<xs:restriction base="xs:string" >
|
||||
<!-- TODO: Moodle 2.5 - Drop LOB sizes, keep only numbers -->
|
||||
<xs:pattern value='(\d+)|(small|medium|big)'/>
|
||||
</xs:restriction >
|
||||
</xs:simpleType >
|
||||
|
@ -75,7 +75,7 @@ class xmldb_field extends xmldb_object {
|
||||
* Set all the attributes of one xmldb_field
|
||||
*
|
||||
* @param string type XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY
|
||||
* @param string precision length for integers and chars, two-comma separated numbers for numbers and 'small', 'medium', 'big' for texts and binaries
|
||||
* @param string precision length for integers and chars, two-comma separated numbers for numbers
|
||||
* @param string unsigned XMLDB_UNSIGNED or null (or false)
|
||||
* @param string notnull XMLDB_NOTNULL or null (or false)
|
||||
* @param string sequence XMLDB_SEQUENCE or null (or false)
|
||||
@ -97,6 +97,11 @@ class xmldb_field extends xmldb_object {
|
||||
$this->sequence = !empty($sequence) ? true : false;
|
||||
$this->setDefault($default);
|
||||
|
||||
if ($this->type == XMLDB_TYPE_BINARY || $this->type == XMLDB_TYPE_TEXT) {
|
||||
$this->length = null;
|
||||
$this->decimals = null;
|
||||
}
|
||||
|
||||
$this->previous = $previous;
|
||||
}
|
||||
|
||||
@ -266,19 +271,10 @@ class xmldb_field extends xmldb_object {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
/// Check for big, medium, small to be applied to text and binary
|
||||
/// Remove length from text and binary
|
||||
if ($this->type == XMLDB_TYPE_TEXT ||
|
||||
$this->type == XMLDB_TYPE_BINARY) {
|
||||
if (!$length) {
|
||||
$length == 'big';
|
||||
}
|
||||
if ($length != 'big' &&
|
||||
$length != 'medium' &&
|
||||
$length != 'small') {
|
||||
$this->errormsg = 'Incorrect LENGTH attribute for text and binary fields (only big, medium and small allowed)';
|
||||
$this->debug($this->errormsg);
|
||||
$result = false;
|
||||
}
|
||||
$length = null;
|
||||
}
|
||||
/// Finally, set the length
|
||||
$this->length = $length;
|
||||
@ -549,36 +545,10 @@ class xmldb_field extends xmldb_object {
|
||||
$this->length = $adofield->max_length;
|
||||
}
|
||||
if ($this->type == XMLDB_TYPE_TEXT) {
|
||||
switch (strtolower($adofield->type)) {
|
||||
case 'tinytext':
|
||||
case 'text':
|
||||
$this->length = 'small';
|
||||
break;
|
||||
case 'mediumtext':
|
||||
$this->length = 'medium';
|
||||
break;
|
||||
case 'longtext':
|
||||
$this->length = 'big';
|
||||
break;
|
||||
default:
|
||||
$this->length = 'small';
|
||||
}
|
||||
$this->length = null;
|
||||
}
|
||||
if ($this->type == XMLDB_TYPE_BINARY) {
|
||||
switch (strtolower($adofield->type)) {
|
||||
case 'tinyblob':
|
||||
case 'blob':
|
||||
$this->length = 'small';
|
||||
break;
|
||||
case 'mediumblob':
|
||||
$this->length = 'medium';
|
||||
break;
|
||||
case 'longblob':
|
||||
$this->length = 'big';
|
||||
break;
|
||||
default:
|
||||
$this->length = 'small';
|
||||
}
|
||||
$this->length = null;
|
||||
}
|
||||
/// Calculate the decimals of the field
|
||||
if ($adofield->max_length > 0 &&
|
||||
@ -709,10 +679,6 @@ class xmldb_field extends xmldb_object {
|
||||
$o .= ')';
|
||||
}
|
||||
}
|
||||
if ($this->type == XMLDB_TYPE_TEXT ||
|
||||
$this->type == XMLDB_TYPE_BINARY) {
|
||||
$o .= ' (' . $this->length . ')';
|
||||
}
|
||||
/// not null
|
||||
if ($this->notnull) {
|
||||
$o .= ' not null';
|
||||
|
@ -721,7 +721,7 @@ class xmldb_table extends xmldb_object {
|
||||
*
|
||||
* @param string name name of the field
|
||||
* @param string type XMLDB_TYPE_INTEGER, XMLDB_TYPE_NUMBER, XMLDB_TYPE_CHAR, XMLDB_TYPE_TEXT, XMLDB_TYPE_BINARY
|
||||
* @param string precision length for integers and chars, two-comma separated numbers for numbers and 'small', 'medium', 'big' for texts and binaries
|
||||
* @param string precision length for integers and chars, two-comma separated numbers for numbers
|
||||
* @param string unsigned XMLDB_UNSIGNED or null (or false)
|
||||
* @param string notnull XMLDB_NOTNULL or null (or false)
|
||||
* @param string sequence XMLDB_SEQUENCE or null (or false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user