Hello there, I have an issue when putting an ActiveRecord model into the Rails.cache. The issue seems to be caused by the published_on column, which is a MySQL datetime column and supports dates between ''1000-01-01 00:00:00'' and ''9999-12-31 23:59:59''. However Rails appears to load this into a class which can''t support a similar range of dates:> p = Product.find_by_gtin("9781418133399") > p.published_on=> Sun, 01 Jan 1899 00:00:00 EST +10:00> Rails.cache.write("test", p)ArgumentError: year too big to marshal: 1898 UTC from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/core_ext/time/marshal.rb:54:in `_dump'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/core_ext/time/marshal.rb:54:in `_dump'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/cache.rb:561:in `dump'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/cache.rb:561:in `initialize'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/cache.rb:363:in `new'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/cache.rb:363:in `block in write'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/cache.rb:520:in `instrument'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/activesupport-3.2.2/lib/active_support/cache.rb:362:in `write'' from (irb):141 from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'' from /Users/dkam/Development/Booko/mysql2/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'' from script/rails:6:in `require'' from script/rails:6:in `<main>'' Is this a bug or am I doing something wrong? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Tb3jlIx2kgMJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Mar 22, 2012 at 7:11 PM, dkam <daniel.milne-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The issue seems to be caused by the published_on column, which is a MySQL > datetime column and supports dates between ''1000-01-01 00:00:00'' and > ''9999-12-31 23:59:59''. However Rails appears to load this into a class > which can''t support a similar range of dates:>> p.published_on > => Sun, 01 Jan 1899 00:00:00 EST +10:00 > >> Rails.cache.write("test", p) > ArgumentError: year too big to marshal: 1898 UTCPerhaps not helpful, but no issue here ( also with Rails 3.2.2, MySQL 5.5.19, cache_store => :file_store ) -- 1.9.2-p290 :002 > oldtimes = Date.new(1899, 1, 1) => Sun, 01 Jan 1899 ... snip thumb-fingered-ness 1.9.2-p290 :004 > oldtimes.to_datetime => Sun, 01 Jan 1899 00:00:00 +0000 1.9.2-p290 :005 > Rails.cache.write("oldtimes", oldtimes) => true 1.9.2-p290 :006 > Rails.cache.read("oldtimes") => Sun, 01 Jan 1899 1.9.2-p290 :007 > user = User.last .... 1.9.2-p290 :009 > user.invitation_sent_at= oldtimes => Sun, 01 Jan 1899 1.9.2-p290 :010 > user.save! (0.7ms) BEGIN (8.3ms) UPDATE `users` SET `invitation_sent_at` = ''1899-01-01 08:00:00'', `updated_at` = ''2012-03-23 02:49:16'' WHERE `users`.`id` = 5 (0.9ms) COMMIT => true 1.9.2-p290 :011 > HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 23/03/2012, at 2:04 PM, Hassan Schroeder wrote:> On Thu, Mar 22, 2012 at 7:11 PM, dkam <daniel.milne-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> The issue seems to be caused by the published_on column, which is a MySQL >> datetime column and supports dates between ''1000-01-01 00:00:00'' and >> ''9999-12-31 23:59:59''. However Rails appears to load this into a class >> which can''t support a similar range of dates: > >>> p.published_on >> => Sun, 01 Jan 1899 00:00:00 EST +10:00 >> >>> Rails.cache.write("test", p) >> ArgumentError: year too big to marshal: 1898 UTC > > Perhaps not helpful, but no issue here ( also with Rails 3.2.2, > MySQL 5.5.19, cache_store => :file_store ) -- > > 1.9.2-p290 :002 > oldtimes = Date.new(1899, 1, 1) > => Sun, 01 Jan 1899 > ... snip thumb-fingered-ness > 1.9.2-p290 :004 > oldtimes.to_datetime > => Sun, 01 Jan 1899 00:00:00 +0000 > 1.9.2-p290 :005 > Rails.cache.write("oldtimes", oldtimes) > => true > 1.9.2-p290 :006 > Rails.cache.read("oldtimes") > => Sun, 01 Jan 1899 > 1.9.2-p290 :007 > user = User.last > .... > 1.9.2-p290 :009 > user.invitation_sent_at= oldtimes > => Sun, 01 Jan 1899 > 1.9.2-p290 :010 > user.save! > (0.7ms) BEGIN > (8.3ms) UPDATE `users` SET `invitation_sent_at` = ''1899-01-01 > 08:00:00'', `updated_at` = ''2012-03-23 02:49:16'' WHERE `users`.`id` = 5 > (0.9ms) COMMIT > => true > 1.9.2-p290 :011 >The issue is with pushing an ActiveSupport::TimeWithZone into the cache, rather than a Date or DateTime in your example. When you load the user from the, is the invitation_sent_at an ActiveSupport::TimeWithZone? And if it is, can you put the user in the cache? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Mar 22, 2012 at 8:13 PM, Dan Milne <daniel.milne-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The issue is with pushing an ActiveSupport::TimeWithZone into the cache, rather than a Date or DateTime in your example. When you load the user from the, is the invitation_sent_at an ActiveSupport::TimeWithZone? And if it is, can you put the user in the cache?Ah, interesting -- 1.9.2-p290 :008 > user.invitation_sent_at.class => ActiveSupport::TimeWithZone ... 1.9.2-p290 :010 > Rails.cache.write("user_invitation_sent_at", user.invitation_sent_at) ArgumentError: year too big to marshal: 1899 UTC from /Users/hassan/.rvm/gems/ruby-1.9.2-p290@happyhouse/gems/activesupport-3.2.2/lib/active_support/core_ext/time/marshal.rb:54:in `_dump'' mmmm... -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.