distal-attribute
distal-attribute
distal-attribute
distal-attribute

date column default

samhill5215 posted 3 years ago in Feature discussion
Prior to v7 a DATE column would automatically default to today's date when a new row was inserted. This no longer happens. Any ideas on why this change?
jfalch posted 3 years ago
yes. a user put up lots of posts on how his company needed this to be so, and it was changed accordingly.
I think of him and his needs every few days when I have to enter lots of expenses into a table by hand, and have to explicitly type today´s date for every one.
ansgar posted 3 years ago
Exactly, see issue #2708. I tend to revert that stuff. There are more people asking for this removed feature than there are complaining about this good default value.
samhill5215 posted 3 years ago
Wow, there sure has been lots of discussion on this and I'm almost sorry for opening this can of worms again. Had I been aware of it I would have certainly weighed in.

Here's my take: Although in theory I agree with djdjohnson that heidi shouldn't modify existing values I have to wonder why any good database designer would allow a NULL in a date field? I also agree with jfalch that preventing incorrect data entry is more appropriate of a custom data entry system, not a mysql qui. But that's another discussion.

How about either (or both) of these compromises?

1. Make the default of NULLs a configurable item. Even better, allow defaults to be defined as the result of a function. In my case the default of the DATE column could be the output of curdate(). It would correct what in my view is a serious defect of mysql.

2. Provide a configurable shortcut for the context menu. As it now exists the only shortcut is for the NULL.

In the absence of either it would be wonderful if the context menu were available in edit mode as well. As it now stands, we who liked the previous default behavior now must use quite a few additional keystrokes or mouse clicks to get something that used to be automatic.

Since my solutions will require coding only anse can determine their feasibility. Frankly I'm grateful heidi even exists so thank you anse.
jfalch posted 3 years ago
IMHO (1) would be the best solution for everyone; the simple version ("set new DATE fields to today´s date") would probably be sufficient for most.

ansgar posted 3 years ago
See issue #2708
ansgar posted 3 years ago
Done. See Tools > Preferences > Data > "Prefill empty date/time fields". This is by default checked, so NULLs are again automatically filled with a SELECT NOW() result. If you uncheck that option, the editor starts with an empty mask, and leaving the editor without entering anyting won't touch the originaly value.
jfalch posted 3 years ago
Thank you !
samhill5215 posted 3 years ago
Yes indeed anse, thank you. Now could you do the same for DATETIME columns? Also the default for TIMESTAMP columns no longer works when setting it to CURRENT_TIMESTAMP.
ansgar posted 3 years ago
All date/datetime/time/timestamp columns should be handled with the above mentioned approach. What exactly does not work?

samhill5215 posted 3 years ago
Oops.. Sorry anse, my mistake. It works as you say. Thanks again.

Please login to leave a reply, or register at first.