New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improper handling of DATE field with DEFAULT clause #1800
Comments
I just created the same table here on MariaDB, and the table designer shows me "curdate()" as an expression, plus the dropdown has that function name: Could be this is only an issue on MySQL, not on MariaDB. Are you using HeidiSQL on Gentoo Linux or was that the server OS? Your screens look like you're not on Wine but Windows. This is related to #1666 for which I added CURDATE to the functions-mariadb.ini, but not to functions-mysql.ini - will do that now. |
@ansgarbecker Yes I was running HeiqiSQL under Windows, connected via TCP/IP to MySQL under Gentoo Linux.
Unlikely, given that mysql CLI does fine. Interestingly, I patched that ini file and CURDATE() is now present in the function list, but table editor STILL messes up it with string literal :( |
Handling of default expressions of MySQL and MariaDB in HeidiSQL is different. See my On top of that, MySQL up to v8.0.13 was different than newer versions (like yours). See the docs: https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html#data-type-defaults-explicit-old |
…ions in a column's default value, for MySQL 8.0.13+ which seems to allow just all functions as default value.
Yes, the column editor how displays expression correctly. You almost fixed it. However... Unless one manually adds the parentheses around the expression in the editor, the ALTER statement produces a syntax error as it lacks the parentheses too. Would it be prudent to automatically enclose the expression in the parentheses?
|
Definitely, the table editor should wrap in parentheses. Just modified that for the next nightly build. |
Now it works fine, thank you very much. |
Thank you for your consistent feedback! |
Preconditions
HeidiSQL version: 12.4.0.6670
MySQL 8.0.32
OS: Gentoo Linux
Describe the bug
I was creating a table with DATE field and I wanted default clause for it to be (CURDATE()). Here's how it is done in mysql CLI:
I then tried to do the same in HeidiSQL. But it seems to be unaware of CURDATE() and/or of the fact that default clauses for DATE fields can be expressions.
To Reproduce
First of all, CURDATE() is missing from the function list
But that's OK, I can type it in. So HeidiSQL does this:
CREATE TABLE `test` ( `pdate` INT NULL DEFAULT (CURDATE()) ) COLLATE='utf8mb4_0900_ai_ci' ;
And it kind of works. But then after I refresh, table editor shows default clause as a string literal???
And the editor of the column is messed up too.
Screenshots or Crash reports
It does not crash per se, but makes any table alterations a big hassle.
The text was updated successfully, but these errors were encountered: