mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
MySQL 5.7 datetime precision support #5428
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jonny-no1 on GitHub (Feb 25, 2017).
Originally assigned to: @Majkl578 on GitHub.
Source: https://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html
This has already been done for Mongo DB, see https://github.com/doctrine/mongodb-odm/issues/1061 and https://github.com/doctrine/mongodb-odm/issues/1063.
@coudenysj commented on GitHub (Aug 21, 2017):
See https://github.com/doctrine/dbal/issues/1020
@holtkamp commented on GitHub (Mar 30, 2018):
Also see https://github.com/doctrine/dbal/issues/2873
@TomHAnderson commented on GitHub (Sep 7, 2018):
Here's a work around: https://blog.tomhanderson.com/2018/09/datetime-with-microseconds-for-mysql-in.html
@flaushi commented on GitHub (Apr 1, 2019):
@TomHAnderson Thanks for that!
In order for your code to also be compatible with postgres, I added
@TomHAnderson commented on GitHub (Apr 1, 2019):
@flaushi Using the Timestamp data type in MySQL can be odd. I recommend you use
DATETIME(6)for your MySQL instead of timestamp: https://stackoverflow.com/questions/409286/should-i-use-the-datetime-or-timestamp-data-type-in-mysql@flaushi commented on GitHub (Apr 1, 2019):
You are right, I had a typo.
@flaushi commented on GitHub (Apr 1, 2019):
Actually I don't even understand, why doctrine cuts off the microsecond part.
Until I ran into trouble with this, I was naturally assuming microseconds would be stored.
AFAIK, a timestamp has 8 bytes on mysql in any case, so it also has nothing to do with saving storage. I bet I am not the only one who sorts by date (I use uuids as primary key). So, anybody seeking for the newest row will run into trouble if more than one row is created in the same second.
https://github.com/doctrine/dbal/issues/2873
@Majkl578 commented on GitHub (Apr 2, 2019):
Wery likely due to portability and compatibility, but as seen in doctrine/dbal#2873 this is something that can be improved in DBAL 3.0.
I'm going to close this issue in favor of doctrine/dbal#2873, please continue discussion there.
@Majkl578 commented on GitHub (Apr 2, 2019):
Duplicate of doctrine/dbal#2873