]> git.joonet.de Git - adminer.git/commitdiff
Allow empty default enum
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 6 Oct 2008 15:41:43 +0000 (15:41 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 6 Oct 2008 15:41:43 +0000 (15:41 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@522 7c3ca157-0c34-0410-bff1-cbf682f78f5c

edit.inc.php
editing.inc.php

index bd62f46f9d58fe3353082853121b13376d7934a3..63e5ad3070277e63d88d68549b7c0188aaaa0ea2 100644 (file)
@@ -21,7 +21,7 @@ if ($_POST && !$error && !isset($_GET["select"])) {
                                } elseif ($field["type"] == "timestamp") {
                                        $set[] = " MODIFY " . idf_escape($name) . " timestamp" . ($field["null"] ? " NULL" : "") . " DEFAULT $val" . ($_POST["on_update"][bracket_escape($name)] ? " ON UPDATE CURRENT_TIMESTAMP" : "");
                                } else {
-                                       $set[] = " ALTER " . idf_escape($name) . ($val == ($field["null"] ? "NULL" : "''") ? " DROP DEFAULT" : " SET DEFAULT $val");
+                                       $set[] = " ALTER " . idf_escape($name) . ($val == ($field["null"] || $field["type"] == "enum" ? "NULL" : "''") ? " DROP DEFAULT" : " SET DEFAULT $val");
                                }
                        }
                }
index cbac8fa54e4ed62eb6a8b67aabc8596fdcc81ab8..295ada11096a597a36c1bf26766f0db773d6ca4e 100644 (file)
@@ -6,8 +6,8 @@ function input($name, $field, $value) {
                if (isset($_GET["select"])) {
                        echo ' <label><input type="radio" name="fields[' . $name . ']" value="-1" checked="checked" /><em>' . lang('original') . '</em></label>';
                }
-               if ($field["null"]) {
-                       echo ' <label><input type="radio" name="fields[' . $name . ']" value=""' . (isset($value) || isset($_GET["select"]) ? '' : ' checked="checked"') . ' /><em>NULL</em></label>';
+               if ($field["null"] || isset($_GET["default"])) {
+                       echo ' <label><input type="radio" name="fields[' . $name . ']" value=""' . (($field["null"] ? isset($value) : strlen($value)) || isset($_GET["select"]) ? '' : ' checked="checked"') . ' />' . ($field["null"] ? '<em>NULL</em>' : '') . '</label>';
                }
                if (!isset($_GET["default"])) {
                        echo '<input type="radio" name="fields[' . $name . ']" value="0"' . ($value === 0 ? ' checked="checked"' : '') . ' />';
@@ -21,7 +21,10 @@ function input($name, $field, $value) {
        } else {
                $first = (isset($_GET["select"]) ? 2 : 1);
                $onchange = ($field["null"] || isset($_GET["select"]) ? ' onchange="var f = this.form[\'function[' . addcslashes($name, "\r\n'\\") . ']\']; f.selectedIndex = Math.max(f.selectedIndex, ' . $first . ');"' : '');
-               $options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : (preg_match('~date|time~', $field["type"]) ? array("", "now") : array("")));
+               $options = array("");
+               if (!isset($_GET["default"]) && preg_match('~char|date|time~', $field["type"])) {
+                       $options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now"));
+               }
                if ($field["null"]) {
                        array_unshift($options, "NULL");
                }