Robert Rouse
2010-Sep-14 05:11 UTC
Mysql2 throws errors on invalid dates. Need suggestion for catching
A dataset I''m working with has bad dates in it (2010-00-09 for example). This causes Mysql2 to throw an error at the adapter level. How am I supposed to catch it so I can handle it correctly? I don''t think it fails in ActiveRecord land, so I''m not sure how to handle it. I figured since Rails 3 uses it by default, someone here would have some experience. I know I could fix the data, but I''m not sure when/if another batch will come in like that and I want to make sure my app is bulletproof. Thanks -- 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.
Wincent Colaiuta
2010-Sep-14 08:12 UTC
Re: Mysql2 throws errors on invalid dates. Need suggestion for catching
On 14 sep, 07:11, Robert Rouse <robert.e.ro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I know I could fix the data, but I''m not sure when/if another batch > will come in like that and I want to make sure my app is bulletproof.Seems like you should fix the data, and add validations to ensure that bad data doesn''t get into the database again. Cheers, Wincent -- 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.
Robert Rouse
2010-Sep-20 04:06 UTC
Re: Mysql2 throws errors on invalid dates. Need suggestion for catching
I''m not in control of the data and it comes in external to my app. It''s an infrastructure I can''t change. If I had control, I would do what you suggested. On Sep 14, 3:12 am, Wincent Colaiuta <w...-uEs3UDB2KWBBDgjK7y7TUQ@public.gmane.org> wrote:> On 14 sep, 07:11, Robert Rouse <robert.e.ro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I know I could fix the data, but I''m not sure when/if another batch > > will come in like that and I want to make sure my app is bulletproof. > > Seems like you should fix the data, and add validations to ensure that > bad data doesn''t get into the database again. > > Cheers, > Wincent-- 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.
radhames brito
2010-Sep-20 05:09 UTC
Re: Re: Mysql2 throws errors on invalid dates. Need suggestion for catching
make a before save method in the model and user a regular expression to translate the date i do something similar changing oracle to mysql. -- 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.
Marnen Laibow-Koser
2010-Sep-20 15:49 UTC
Re: Mysql2 throws errors on invalid dates. Need suggestion for catching
Please quote when replying. It''s very hard to follow the discussion otherwise. Robert Rouse wrote:> I''m not in control of the data and it comes in external to my app. > It''s an infrastructure I can''t change. > > If I had control, I would do what you suggested.Well, if you''re getting fed bad data, it''s not reasonable for your end-users to expect good results. Garbage in, garbage out. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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.