What is the difference between CURRENT_TIMESTAMP and current_timestamp() ?
I'm using laravel, and in the laravel migration file for my Tasks table I have this:
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
For my database container, I am using a local docker setup with: mariadb:latest (seems to be bringing up version 10.8.3-MariaDB-1:10.8.3+maria~jammy (mariadb.org binary distribution) )
and the weird thing is..
I have Sequel Pro open, and when trying to manually insert a record ( for testing purposes ) through the sequel pro interface and it is failing with the following error:
Incorrect datetime value: 'current_timestamp()' for column .. created_at
..
Notice when I click to add a new row, the defaults are 'current_timestamp()'
If I manually change these defaults to 'CURRENT_TIMESTAMP' instead of 'current_timestamp()' it seems to work:
The function/call or lower case version of CURRENT_TIMESTAMP does not work...
If I add a new row programatically / with laravel:
$newTask = new Task();
$newTask->title = 'testing';
$newTask->save();
the row is inserted properly ( with the current timestamp values.. ):
Where is this problem at?
- Laravel side/configuration?
- Could it be the 'mariadb:latest' bringing up a bug?
- Could it be a sequel pro bug ?
This is the create table definition btw:
CREATE TABLE `tasks` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;