Menu

#572 adminer generate wrong alter table statement (timestamp)

4.3.1
closed-fixed
nobody
None
5
2018-01-23
2017-09-26
kbudde
No

Hello,

I use adminer 4.3.1 with MariaDB 10.2.8.
When I want to update a table definition, which have a timestamp column with the default "current_timestamp() on update current_timestamp()", then adminer generate a wrong sql statement.

The original create statement for the table is:
CREATE TABLE table_test (
def_id int(10) unsigned NOT NULL COMMENT 'DefinitionsId',
change_date timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Änderungsdatum',
PRIMARY KEY (def_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Now I want to add a new Column to the table (see the screenshot "adminer_add_Column.png").

When I want to save the changes, I become the following error (see the screenshot "adminer_error.png"):
Incorrect datetime value: 'current_timestamp()' for column 'change_date' at row 1

The wrong adminer statement is:
ALTER TABLE table_test
ADD data text NOT NULL COMMENT 'Testdaten' AFTER def_id,
CHANGE change_date change_date timestamp NOT NULL DEFAULT 'current_timestamp()' COMMENT 'Änderungsdatum' AFTER data;

The correct statement must be:
ALTER TABLE table_test
ADD data text NOT NULL COMMENT 'Testdaten' AFTER def_id,
CHANGE change_date change_date timestamp NOT NULL DEFAULT current_timestamp() on update current_timestamp() COMMENT 'Änderungsdatum' AFTER data;

Can you fix the wrong statement generation?

Kind regards,
kbudde

2 Attachments

Discussion

  • Jakub Vrána

    Jakub Vrána - 2018-01-23
    • status: open --> closed-fixed
     
  • Jakub Vrána

    Jakub Vrána - 2018-01-23

    MySQL uses CURRENT_TIMESTAMP (no braces). I've added support for current_timestamp() too.

     

Log in to post a comment.