]> git.joonet.de Git - adminer.git/commitdiff
Delete length when changing type
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 17 Dec 2009 12:54:17 +0000 (12:54 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 17 Dec 2009 12:54:17 +0000 (12:54 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1272 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/include/editing.inc.php
adminer/include/mysql.inc.php
adminer/static/editing.js
changes.txt

index 7a578c00f7636103a18257db9ec83cd0de3a239d..e29653121c373dba200efbd274d882974dc73c35 100644 (file)
@@ -108,7 +108,7 @@ function referencable_primary($self) {
 function edit_type($key, $field, $collations, $foreign_keys = array()) {
        global $structured_types, $unsigned, $inout;
        ?>
-<td><select name="<?php echo $key; ?>[type]" class="type" onchange="editing_type_change(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
+<td><select name="<?php echo $key; ?>[type]" class="type" onfocus="last_type = select_value(this);" onchange="editing_type_change(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
 <td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editing_length_focus(this);">
 <td><?php
        echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
index b578de522e9e8c013ed3fe27d26f66009aaaf322..3b3dcc56ca6df19d84114d647d98f822642b0d1d 100644 (file)
@@ -385,7 +385,7 @@ function exact_value($val) {
 $types = array();
 $structured_types = array();
 foreach (array(
-       lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "float" => 12, "double" => 21, "decimal" => 66),
+       lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21),
        lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4),
        lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295),
        lang('Binary') => array("binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295),
index 3b86349550cb50287209bdd0fbd94bd4b2098d5e..e6172e5215ecb56e06462bc6c3810f533c45b968 100644 (file)
@@ -146,11 +146,18 @@ function editing_remove_row(button) {
        return true;
 }
 
+var last_type = '';
 function editing_type_change(type) {
        var name = type.name.substr(0, type.name.length - 6);
        var text = select_value(type);
        for (var i=0; i < type.form.elements.length; i++) {
                var el = type.form.elements[i];
+               if (el.name == name + '[length]' && !(
+                       (/(char|binary)$/.test(last_type) && /(char|binary)$/.test(text))
+                       || (/(enum|set)$/.test(last_type) && /(enum|set)$/.test(text))
+               )) {
+                       el.value = '';
+               }
                if (el.name == name + '[collation]') {
                        el.className = (/(char|text|enum|set)$/.test(text) ? '' : 'hidden');
                }
index 95c378d6f62901102f3df53258284348c84f352c..e58f928fae8c10dba031d32a6abbfb8b5fe90f0c 100644 (file)
@@ -1,6 +1,8 @@
 Adminer 2.2.2-dev:
 Add Delete button to Edit page (regression from 2.0.0)
 Simplify SQL syntax error message
+Print SQL query info if available
+Delete length when changing type
 
 Adminer 2.2.1 (released 2009-11-26):
 Highlight current links