New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL 5.6 and later supports microsecond precision in datetime. #8240
Conversation
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.
Nice! How about a test case to demonstrate microsecond precision? |
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).
|
+1. Anything that can be done to help here? I would be happy to help write a test case, but since the dev box is running MySQL 5.5.29 at the moment, the case would not pass there. |
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. |
Any status on this? We're pretty stuck to MySQL, but caching becomes a bother when my cache keys don't have better precision. |
Rails is now using mysql 0.3.12+, so the microsecond precision is available in the library. There's no MySQL 5.6 on Travis though, so any tests would have to be trusted from local testers at the moment. |
To get this all the way there I think we'd need precision support in MySQL migrations as well - something not too unlike 96ce1f2 . |
any update on this? |
@amatsuda ping |
Merged in at #14359 |
Thanks a lot for the patch. We merged your commit on #14359 . |
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
updated_at
. This is significant to take benefits from cache_key second precision updated to nanoseconds.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.