From: jakubvrana Date: Mon, 6 Oct 2008 15:41:43 +0000 (+0000) Subject: Allow empty default enum X-Git-Tag: v3.0.0~996 X-Git-Url: https://git.joonet.de/?a=commitdiff_plain;h=79969ae060c98bdee0040b417baaf9dc6de5229d;p=adminer.git Allow empty default enum git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@522 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- diff --git a/edit.inc.php b/edit.inc.php index bd62f46f..63e5ad30 100644 --- a/edit.inc.php +++ b/edit.inc.php @@ -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"); } } } diff --git a/editing.inc.php b/editing.inc.php index cbac8fa5..295ada11 100644 --- a/editing.inc.php +++ b/editing.inc.php @@ -6,8 +6,8 @@ function input($name, $field, $value) { if (isset($_GET["select"])) { echo ' '; } - if ($field["null"]) { - echo ' '; + if ($field["null"] || isset($_GET["default"])) { + echo ' '; } if (!isset($_GET["default"])) { echo ''; @@ -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"); }