]> git.joonet.de Git - adminer.git/commitdiff
MySQL 5.6.5+: Support ON UPDATE on datatime column (bug #393)
authorJakub Vrana <jakub@vrana.cz>
Sat, 15 Mar 2014 21:08:34 +0000 (14:08 -0700)
committerJakub Vrana <jakub@vrana.cz>
Sat, 15 Mar 2014 21:08:34 +0000 (14:08 -0700)
adminer/include/editing.inc.php
adminer/static/editing.js
changes.txt

index 6f16373fb00b20a8c2a7dd221f0a5b558e332a66..71bd5bc09434b27d8dfde955a1414404c09ddf21 100644 (file)
@@ -152,7 +152,7 @@ echo optionlist($structured_types, $type);
 <td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> onchange="editingLengthChange(this);" onkeyup="this.onchange();"><td class="options"><?php //! type="number" with enabled JavaScript
        echo "<select name='$key" . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$type || preg_match('~((^|[^o])int|float|double|decimal)$~', $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
-       echo (isset($field['on_update']) ? "<select name='$key" . "[on_update]'" . ($type == "timestamp" ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
+       echo (isset($field['on_update']) ? "<select name='$key" . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
        echo ($foreign_keys ? "<select name='$key" . "[on_delete]'" . (preg_match("~`~", $type) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
 }
 
@@ -199,7 +199,7 @@ function process_field($field, $type_field) {
                        || ($field["type"] == "bit" && preg_match("~^([0-9]+|b'[0-1]+')\$~", $default))
                        || ($jush == "pgsql" && preg_match("~^[a-z]+\\(('[^']*')+\\)\$~", $default))
                        ? $default : q($default)) : ""),
-               ($field["type"] == "timestamp" && $field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
+               (preg_match('~timestamp|datetime~', $field["type"]) && $field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
                (support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
                ($field["auto_increment"] ? auto_increment() : null),
        );
index 556286228eeb9c6f87726b5477d148634ec47c51..b07d2c200fb17f59162e0bf11fe22ac30dbc385e 100644 (file)
@@ -312,7 +312,7 @@ function editingTypeChange(type) {
                        alterClass(el, 'hidden', !/((^|[^o])int|float|double|decimal)$/.test(text));
                }
                if (el.name == name + '[on_update]') {
-                       alterClass(el, 'hidden', text != 'timestamp');
+                       alterClass(el, 'hidden', !/timestamp|datetime/.test(text)); // MySQL supports datetime since 5.6.5
                }
                if (el.name == name + '[on_delete]') {
                        alterClass(el, 'hidden', !/`/.test(text));
index 39943fb2b8f5875dd94e0d13057212692ab0fe0a..26aedb88eea0287ca6ca6bdc9b686b0cc10764a7 100644 (file)
@@ -7,6 +7,7 @@ Print elapsed time in HTML instead of SQL command comment
 Improve gzip export ratio (bug #387)
 MySQL: Fix editing rows by binary values, bug since Adminer 3.7.1
 MySQL: Respect daylight saving time in dump, bug since Adminer 3.6.4
+MySQL 5.6.5+: Support ON UPDATE on datatime column
 SQLite: Support UPDATE OF triggers
 SQLite: Display auto-created unique indexes, bug since Adminer 3.5.0
 Editor: Fix login() method, bug since Adminer 4.0.0