On Tue, 9 May 2006, Xavier wrote:
The issue here is that ActiveRecord’s SQL/Ruby type mapper explicitly
uses Time and the exception is raised in there, not in my application
code…
I knew there was a reason I never use DB date/time fields! I almost
always use char(14), and store YYYYMMDDHHMMSS. They sort right as
strings
or numbers, and I’ve yet to run in to a tool that can’t extract dates
and
times from them.
As has been suggested, the simplest might be not to use a format that AR
knows is a Time and then write some code to parse/format them.
My cheesy workaround aside, could you reimplement Time itself?
If I understand correctly, Ruby classes are open, so you could just
implement the class again, using a different storage mechanism. AR
would
use it, and not mind the bigger numbers any more.
That could be a huge PITA to get right, though, as time is hard. (As
someone who’s had to implement all of this in C, repeatedly, I feel I am
qualified to say that.)
It might be easier to override/replace the piece of ActiveRecord that
decided that particular field type in the db maps to a Time object. I’m
not sure which would be less painful. DateTime looks like it stores
things in a less brittle format, but it might have other limits.
I haven’t heard of anyone else who’s done this already.
–
Louis Erickson - [email protected] - Lou's Home Page!
“Here at the Phone Company, we serve all kinds of people; from
Presidents and Kings to the scum of the earth …”