]> git.joonet.de Git - adminer.git/commitdiff
Detect removed default (thanks to cvicebni ubor)
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 14 Sep 2009 16:07:35 +0000 (16:07 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 14 Sep 2009 16:07:35 +0000 (16:07 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1109 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/create.inc.php
adminer/include/editing.inc.php

index 115bb341368d40ad190057a050471d60552ea88e..506c05b7cf1c030e84e457c4da99f829c4878b8a 100644 (file)
@@ -37,6 +37,9 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
                $type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
                if (strlen($field["field"])) {
                        if ($type_field) {
+                               if (!$field["has_default"]) {
+                                       $field["default"] = null;
+                               }
                                $process_field = process_field($field, $type_field);
                                $auto_increment = ($key == $_POST["auto_increment_col"]);
                                if ($process_field != process_field($orig_field, $orig_field) || $orig_field["auto_increment"] != $auto_increment) {
index f1e4b38314cb919f3f3f4853ca9b64947976e5eb..990fde8642756c56cc0ea9eae13fff310efc863a 100644 (file)
@@ -124,7 +124,7 @@ function process_field($field, $type_field) {
        global $dbh;
        return idf_escape($field["field"]) . process_type($type_field)
                . ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
-               . (!$field["has_default"] || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $field["default"]) ? $field["default"] : $dbh->quote($field["default"])))
+               . (!isset($field["default"]) || $field["auto_increment"] || ereg('text|blob', $field["type"]) ? "" : " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP( on update CURRENT_TIMESTAMP)?$", $field["default"]) ? $field["default"] : $dbh->quote($field["default"])))
                . " COMMENT " . $dbh->quote($field["comment"])
        ;
 }