Hello! Let me see if this is somehow easy. I have columns in my MySQL database set as ''text'' ( double checked, they''re not accidentally set to the wrong thing). I''m trying to Marshal some data for a special need in the program. Whenever I save this, though, the data (ie the resulting string after marshal) gets chopped to no more than 255 characters. Has there ever been an issue with MySQL doing that or maybe rails thinking it''s the wrong type? I managed to fix it by converting the text fields to ''blob'' data types, but it''s still weird and I''d love to know why. -Ryan def matchattributes self[:matchattributes] ? Marshal.load(self[:matchattributes]) : [] end def matchattributes=(x) self[:matchattributes] = Marshal.dump(x) end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2009-Nov-26 12:42 UTC
Re: Rails Truncating "TEXT" values to 255 characters
On Nov 26, 8:51 am, kopf1988 <kopf1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello! > > Let me see if this is somehow easy. I have columns in my MySQL > database set as ''text'' ( double checked, they''re not accidentally set > to the wrong thing). I''m trying to Marshal some data for a special > need in the program. Whenever I save this, though, the data (ie the > resulting string after marshal) gets chopped to no more than 255 > characters. Has there ever been an issue with MySQL doing that or > maybe rails thinking it''s the wrong type?Use a blob rather than a text column - if you''ve got a text column with the encoding set to utf8 (often to default) mysql will truncate when it sees data that isn''t valid utf8 Fred> > I managed to fix it by converting the text fields to ''blob'' data > types, but it''s still weird and I''d love to know why. > > -Ryan > > def matchattributes > self[:matchattributes] ? Marshal.load(self[:matchattributes]) : [] > end > def matchattributes=(x) > self[:matchattributes] = Marshal.dump(x) > end-- 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.