Bug 153942 - EDITING Default Value "CURRENT_TIMESTAMP" not shown and not saved
Summary: EDITING Default Value "CURRENT_TIMESTAMP" not shown and not saved
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.5.1.2 release
Hardware: All Linux (All)
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-03 15:50 UTC by Philippe Debrabant
Modified: 2023-03-11 13:53 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Debrabant 2023-03-03 15:50:41 UTC
New table, I want a TIMESTAMP column with an automatic value = CURRENT_TIMESTAMP.

If I enter "CURRENT_TIMESTAMP" in the column's default value, save, close and re-open the table, the defaut value is empty and "CURRENT_TIMESTAMP" is not use if I insert a row in the table.

Bypass : I need to run the SQL Query : "ALTER TABLE "my-table" ALTER COLUMN "my-timestamp-column" SET DEFAULT CURRENT_TIMESTAMP"

After that, the default value is still empty in the edit mode, but it is used.
Comment 1 Robert Großkopf 2023-03-10 14:28:07 UTC
There are different default values. If you create a table in the *.odb-file using the GUI of Base, the default value in this GUI is a static default value, which is shown in any new row of the table when creating a new record. CURRENT_TIMESTAMP isn't a static value for now. 2023-03-10 15:27:04 will be such a value for a default timestamp of the GUI.

The same behavior is setting a default value for the GUI in a form. There is no possibility to set a dynamic default value (like CURRENT_DATE, CURRENT_TIMESTAMP) in GUI. You could create such a value by using macro, but it has to change its value while TIME is changing …

The default value of the database will be set if there is no value in a column which. The field is empty, NULL. You have to alter the table definition through Tools → SQL for this.
Comment 2 Philippe Debrabant 2023-03-11 10:19:30 UTC
"You have to alter the table definition through Tools → SQL"

Yes, it's what I did, but I think (as for other database's GUI) this common propertie should be either entered with the Libreoffice Base GUI.

I'm not the only person that search for this usual need. Using Tools / SQL and the ALTER TABLE statement is not as simple as input in the GUI.

So as it's apparently not a bug, could you add an evolution for this need ?
Comment 3 Robert Großkopf 2023-03-11 13:51:00 UTC
It's a very old discussion also in this bugtracker. Have added a link to my old bug report 11 years ago.

I will set this one to an enhancement request.
Comment 4 Robert Großkopf 2023-03-11 13:53:04 UTC
Note: A default value for a timestamp couldn't work as CURRENT_TIMESTAMP in GUI without problems. CURRENT_TIMESTAMP should be the TIMESTAMP for saving the new row, not for opening a form.