diff options
author | Maarten Jacobs <m.jacobs@defacto.nl> | 2015-09-29 13:53:39 +0200 |
---|---|---|
committer | Maarten Jacobs <m.jacobs@defacto.nl> | 2015-10-16 15:09:45 +0200 |
commit | 86d2924a115c2604e4facdf285a7b764938fae0f (patch) | |
tree | 71246c411b4768efa599760eacd336a7f76673f1 /activerecord/lib | |
parent | b3656076d64fabb7a492aa4b8e8d45b6826b8798 (diff) | |
download | rails-86d2924a115c2604e4facdf285a7b764938fae0f.tar.gz rails-86d2924a115c2604e4facdf285a7b764938fae0f.tar.bz2 rails-86d2924a115c2604e4facdf285a7b764938fae0f.zip |
fixes #21815
The default timestamp used for AR is `updated_at` in nanoseconds! (:nsec) This causes issues on any machine that runs an OS that supports nanoseconds timestamps, i.e. not-OS X, where the cache_key of the record persisted in the database (milliseconds precision) is out-of-sync with the cache_key in the ruby VM.
This commit adds:
A test that shows the issue, it can be found in the separate file `cache_key_test.rb`, because
- model couldn't be defined inline
- transactional testing needed to be turned off to get it to pass the MySQL tests
This seemed cleaner than putting it in an existing testcase file.
It adds :usec as a dateformat that calculates datetime in microseconds
It sets precision of cache_key to :usec instead of :nsec, as no db supports nsec precision on timestamps
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/integration.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/integration.rb b/activerecord/lib/active_record/integration.rb index 19d2589db3..466c8509a4 100644 --- a/activerecord/lib/active_record/integration.rb +++ b/activerecord/lib/active_record/integration.rb @@ -10,9 +10,9 @@ module ActiveRecord # Indicates the format used to generate the timestamp in the cache key. # Accepts any of the symbols in <tt>Time::DATE_FORMATS</tt>. # - # This is +:nsec+, by default. + # This is +:usec+, by default. class_attribute :cache_timestamp_format, :instance_writer => false - self.cache_timestamp_format = :nsec + self.cache_timestamp_format = :usec end # Returns a String, which Action Pack uses for constructing a URL to this |