LibreCat / Catmandu-DBI

A Catmandu::Store plugin for DBI based interfaces
Other
0 stars 1 forks source link

Mapping to datetime columns fails for MySQL #20

Closed phochste closed 5 years ago

phochste commented 6 years ago

I have a mapping:

mapping:
            date_updated:
                type: datetime
                required: 1

This generates an error in MySQL 5.5 installations:

BD::mysql::db do failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(3) NOT NULL,`id` VARCHAR(255) BINARY UNIQUE NOT NULL,`date_created` DATETIME(3)' at line 1 at /opt/librecat/local/lib/perl5/Catmandu/Store/DBI/Handler/MySQL.pm line 58.

I guess DATETTIME(3) isnt valid for MySQL

nicolasfranck commented 6 years ago

I think this needs reviewing before merging this with the master branch. Without support for milliseconds the milliseconds, as created by the Catmandu::Plugin::Datestamps, will be lost during save.

phochste commented 6 years ago

Even the datetime(3) implementation has problems. This means that milliseconds are forced onto date. You store 2017-01-01 10:00:00 and get back 2017-01-01 10:00:00.000

nicolasfranck commented 6 years ago

In that case we should make it explicit:

When working the plugin Datestamps one should make sure both are equal to each other

nics commented 5 years ago

already merged