Table Editor doesn't allow default values like `CURRENT_DATE`
See original GitHub issueBug report
Describe the bug
The Table Editor in Studio doesn’t allow default values like CURRENT_DATE. However, it works as expected when done via SQL (both creating and altering a table).
To Reproduce
- Create a new table:
CREATE TABLE testdate (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
date DATE NOT NULL
);
- Go to Table Editor and add default value
CURRENT_DATEto columndate.
This results in the notification: Failed to update column “date”: failed to update pg.columns with the given ID: invalid input syntax for type date: “CURRENT_DATE”
Expected behavior
When using SQL directly, you can set the default value and it works as expected:
ALTER TABLE testdate ALTER COLUMN date SET DEFAULT CURRENT_DATE;
I expect that the Table Editor supports values like CURRENT_DATE. (I have not tested CURRENT_TIME and similar, but expect the same behavior)
Issue Analytics
- State:
- Created a year ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Default value = today's date in MSDE table editor - MSDN - Microsoft
What do I put in the Default value of a DateTime field if I'm using the table editor for a MSDE table and...
Read more >27645: Datetime field does not accept default NOW()
This means, for example, that you cannot set the default for a date column to be the value of a function such as...
Read more >Setting default value for DATE type column to current ...
I have tried: ALTER TABLE `accounting` ALTER `accounting_date` SET DEFAULT CURRENT_DATE; ALTER TABLE `accounting` CHANGE `accounting_date` ` ...
Read more >Changing a Column's Default Value - MySQL Cookbook by
To change a default value, use ALTER col_name SET DEFAULT : ALTER TABLE mytbl ALTER j SET DEFAULT 1000; Default values must be...
Read more >SQL DEFAULT Constraint
The DEFAULT constraint is used to set a default value for a column. The default value will be added to all new records,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This is one of the cases where
defaultValueFormatneeds to be"expression"I think - otherwise"CURRENT_DATE"will be treated (and escaped) as a string literal.hmm but this wouldn’t be right on the UI. esp if a user saved their default value as a literal, and they open the editor again and it shows that Is a SQL expression is toggled true