[ruby-dbi-users] Proposing patch for sqlite3 driver

Jarl Friis jarl at gavia.dk
Wed Oct 1 07:55:11 EDT 2008

Erik Hollensbe <erik at hollensbe.org> writes:

> The problem with this is that while postgres's date format is variable, the 
> parsing routes we use with DateTime are not. A smarter solution needs to be 
> used, as a "strptime until it doesn't break" solution will likely cause more 
> problems than it resolves.

I am not sure on what you mean by "strptime until it doesn't break",
and I wonder what problems you have in mind when you say "will likely
cause more problems than it resolves."

Anyway I think that my proposal is more robust than
current implementation, because:
1) most installations/configurations will accept ISO dates.
2) dates formated in ISO8601 are not unambigous.
3) The current solution silently create corrupt data if you pg is
   configured to use dmy.

As you mention my solution still requires the configuration to accept
iso formats, but it will crash early[1] if pgsql is not configured so,
which is good. This is not the case with current DBD:Pg

So all-in-all I consider my proposal at least as good as the current
implementation. Yet I agree that it could be nice with an even better
solution. The low-level pg-driver accepts a DateTime, could that be used
in stead of handing over a string? Or should we do such thing as 
to_timestamp('2008-09-30 12:34:34.123456','YYYY-MM-DD HH:MM:SS.US');
when writing to the database? In that case we still need to do
something when reading from the database.


[1]  http://www.pragmaticprogrammer.com/the-pragmatic-programmer/extracts/tips

More information about the ruby-dbi-users mailing list