Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
MySQL 5.6 and later supports microsecond precision in datetime. #8240
MySQL 5.6 supports microsecond fraction with datetime functions: http://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html
This patch allows saving microseconds to mysql's datetime columns such as
You might want to branch it to include this only for 5.6, but passing these values to < 5.6 doesn't cause issues either, based on my experiment.
See also a pull request on mysql2 gem that addresses retrieving microseconds from mysql to inflate to Time with typecasting enabled.
According to http://dev.mysql.com/doc/refman/5.0/en/datetime.html it is safe to provide the microseconds without checking the mysql version. This also works correctly even if strict checking is enabled. Only requirement is that microseconds are 6 decimal places or less (@miyagawa's patch is correct for this).
If there's a way to require that Travis uses MySQL 5.6, then we can add that to the Rails matrix and write a test that checks for microseconds when running on 5.6. The fact that it works at all indicates that the change does not cause a problem, but does not indicate that the change does work as intended yet.
According to Travis, there's only Mysql 5.5: http://about.travis-ci.org/docs/user/ci-environment/#Data-Stores
Also we haven't provided a stable release of mysql2 that passes microseconds through, that'll be a prerequisite for tests.