diff --git a/admin/tool/xmldb/actions/edit_field/edit_field.js b/admin/tool/xmldb/actions/edit_field/edit_field.js index b5a45c1377cf8..57dcfcaa2b2da 100644 --- a/admin/tool/xmldb/actions/edit_field/edit_field.js +++ b/admin/tool/xmldb/actions/edit_field/edit_field.js @@ -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 = ''; diff --git a/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php b/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php index a1b4a80fd0a2d..90b1433cbb0dd 100644 --- a/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php +++ b/admin/tool/xmldb/actions/edit_field_save/edit_field_save.class.php @@ -49,8 +49,6 @@ function init() { '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 @@ function invoke() { } } } - // 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); diff --git a/admin/tool/xmldb/lang/en/tool_xmldb.php b/admin/tool/xmldb/lang/en/tool_xmldb.php index ebb4878285945..a378c268ee4a6 100644 --- a/admin/tool/xmldb/lang/en/tool_xmldb.php +++ b/admin/tool/xmldb/lang/en/tool_xmldb.php @@ -27,7 +27,6 @@ $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['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'; diff --git a/lib/ddl/mysql_sql_generator.php b/lib/ddl/mysql_sql_generator.php index f09a8f6de88d3..11e241a0de269 100644 --- a/lib/ddl/mysql_sql_generator.php +++ b/lib/ddl/mysql_sql_generator.php @@ -202,28 +202,10 @@ public function getTypeSQL($xmldb_type, $xmldb_length=null, $xmldb_decimals=null $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'; diff --git a/lib/xmldb/xmldb.xsd b/lib/xmldb/xmldb.xsd index a2079c6dceb99..d30597eae9261 100644 --- a/lib/xmldb/xmldb.xsd +++ b/lib/xmldb/xmldb.xsd @@ -34,6 +34,7 @@ + diff --git a/lib/xmldb/xmldb_field.php b/lib/xmldb/xmldb_field.php index e0819fa0084bc..cec73df60b4fe 100644 --- a/lib/xmldb/xmldb_field.php +++ b/lib/xmldb/xmldb_field.php @@ -75,7 +75,7 @@ function setAttributes($type, $precision=null, $unsigned=null, $notnull=null, $s * 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 @@ function set_attributes($type, $precision=null, $unsigned=null, $notnull=null, $ $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 @@ function arr2xmldb_field($xmlarr) { $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 @@ function setFromADOField($adofield) { $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 @@ function readableInfo() { $o .= ')'; } } - if ($this->type == XMLDB_TYPE_TEXT || - $this->type == XMLDB_TYPE_BINARY) { - $o .= ' (' . $this->length . ')'; - } /// not null if ($this->notnull) { $o .= ' not null'; diff --git a/lib/xmldb/xmldb_table.php b/lib/xmldb/xmldb_table.php index a7011e4620b14..2267a7558c279 100644 --- a/lib/xmldb/xmldb_table.php +++ b/lib/xmldb/xmldb_table.php @@ -721,7 +721,7 @@ function addFieldInfo($name, $type, $precision=null, $unsigned=null, $notnull=nu * * @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)