|
From: Jacob N. <ja...@jf...> - 2005-11-21 02:41:51
|
I've been using HSQL with a PostgreSQL database on Linux, and things have
been going quite swimmingly. Then I started getting errors like this:
start_time is 2005-11-19 16:20:47-08
end_time is 2005-11-19 16:21:33.863-08
*** Exception: HSQL.hsc:323:13-54: Non-exhaustive patterns in case
The first two lines are generated when I pull timestamp fields out as
Strings. The exception on the third line occurs when I try to read the
start_time field as a ClockTime. The end_time field works fine. The
difference appears to be that PostgreSQL doesn't print the millisecond
field on start_time, since it's all zeros.
Armed with this observation, I jumped into the HSQL code. I'm fairly new
to Haskell and certainly new to parser combinators, but I found a
suspicious comment character lurking in the getDateTimeTZ instance of
fromSqlValue, on line 379 of HSQL.hsc:
fromSqlValue SqlDateTimeTZ s = f_read getDateTimeTZ s
where
getDateTimeTZ :: ReadP ClockTime
getDateTimeTZ = do
(year, month, day, hour, minutes, seconds) <- readDateTime
char '.' >> readDecP -- ) `mplus` (return 0)
tz <- parseTZ
return (mkClockTime year month day hour minutes seconds (tz*3600))
When I got rid of it and rebuilt, I no longer got the exception. If I
understand correctly, the mplus clause allows the parser to continue
on if the field has no milliseconds part (although we wouldn't use the
result even if it were there for us to read). Is that correct?
Is this the right change to make?
Thanks for your help,
jacob
|