1

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..

Incorrect datetime value: 'current_timestamp()' for column..

Notice when I click to add a new row, the defaults are 'current_timestamp()' current_timestamp() default

If I manually change these defaults to 'CURRENT_TIMESTAMP' instead of 'current_timestamp()' it seems to work:

enter image description here

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;
Pablo Camara
  • 460
  • 4
  • 13
  • Can you share the ddl? – Jens Aug 27 '22 at 12:07
  • What do you mean by ddl ? 'data definition language'? the CREATE TABLE definition or something? (added to question) - btw I answered my own question because when writing it I tried workbench and discovered that there is a bug with Sequel pro and is not related to my create table definition or laravel or database version.. – Pablo Camara Aug 27 '22 at 12:10
  • If it is a sequel bug, you should create a bug report at the maintainer and link it here so we can see if it is fixed. Also the version where you discovered it will be helpful. – Jens Aug 27 '22 at 17:17
  • Ok, so I went on to try and create a bug report at the maintainer website, and then it redirected me to github issues, then in there I searched for open issues related to the CURRENT_TIMESTAMP and I found some: https://github.com/sequelpro/sequelpro/issues?q=is%3Aissue+is%3Aopen+current_timestamp , but while browsing I also found out they are no longer maintaining it: https://github.com/sequelpro/sequelpro/issues/3705 and that there is an alternative "Sequel-Ace": https://github.com/Sequel-Ace/Sequel-Ace that I have not tried yet but I will .. thanks ! – Pablo Camara Aug 27 '22 at 17:52
  • and I have just tried Sequel-Ace! and the bug is fixed there!! I'm migrating to that one! Sequel Pro alive again! long live sequel pro!! ( through Sequel Ace ) heheh – Pablo Camara Aug 27 '22 at 18:01

1 Answers1

2

While developing this question, I have decided to download MySql Workbench and try inserting the values there through the MySql Workbench interface,

and it seems to work, and it seems that it is because MySql Workbench simply runs INSERT queries:

INSERT INTO `tasks_pabloserver_db`.`tasks` (`title`) VALUES ('teeest');
INSERT INTO `tasks_pabloserver_db`.`tasks` (`title`) VALUES ('test444');

which work and insert the proper default/timestamp values. I looked at the table structure in MySql Workbench and the default value is 'current_timestamp()' and not 'CURRENT_TIMESTAMP', and it still works so it cannot be the database version I guess.

So then I tried to run these same INSERT statements in Sequel Pro and it also worked properly, so my conclusion is that Sequel Pro interface has a bug and that is to blame.

Pablo Camara
  • 460
  • 4
  • 13