| | [Haskell-cafe] programmatic DB interface?  | | 
04-02-10, 08:27 PM
| | | Re: [Haskell-cafe] Re: programmatic DB interface? On Thu, Feb 4, 2010 at 7:38 PM, Colin Paul Adams
<colin@colina.demon.co.uk>wrote:
> >>>>> "Johannes" == Johannes Waldmann <waldmann@imn.htwk-leipzig.de>
> writes:
>
> Johannes> anyone know what's happening here? I get this when
> Johannes> executing a query via haskelldb-hdbc-postgresql-0.12 (The
> Johannes> date is actually in the DB, so it's not a connection
> Johannes> problem.)
>
> Johannes> Convertible: error converting source data SqlString
> Johannes> "2008-10-29 00:00:00" of type SqlValue to type
> Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse
> Johannes> using default format string "%Y-%m-%dT%T%Q"
>
> I had this sort of problem. I sent a patch on the haskell-db list to use
> UTC - I believe the release behaviour is incorrect.
>
> You might check the list archives, as they have a better memory than I.
>
> I actually just came up against this as well in HDBC-postgresql. As a
workaround, when I read a timestamp I concatenate with an empty string
(||'') and then read with my own parse string:
"%Y-%m-%d %T%Q"
This seems to work just fine. I'd like to debug it more, but I'm working on
a short-deadline project. Hopefully when the month is out I'll be able to
submit some patches for the problems I've run into. The other one that comes
to mind off hand is I can't write to BYTEA fields either.
Michael
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
05-02-10, 08:05 AM
| | | Re: [Haskell-cafe] Re: programmatic DB interface?
> Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse
> Johannes> using default format string "%Y-%m-%dT%T%Q"
this actually comes from the default format string
that is defined in old-locale:System.Locale?
iso8601DateFormat :: Maybe String -> String
iso8601DateFormat mTimeFmt =
"%Y-%m-%d" ++ case mTimeFmt of
Nothing -> ""
Just fmt -> 'T' : fmt
and this can't be right - the 'T' is invalid?
J.
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - [url]http://enigmail.mozdev.org[/url]
iEYEARECAAYFAktrwxUACgkQDqiTJ5Q4dm+iggCfcQFt+fqPd6 jq1kvCHQgWktut
50kAni/G/x1AvKjKcNQyyuZ+QYAagNID
=oWnD
-----END PGP SIGNATURE----- | 
05-02-10, 08:55 AM
| | | Re: [Haskell-cafe] Re: programmatic DB interface? On 05/02/10 07:04, Johannes Waldmann wrote:
>
>> Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse
>> Johannes> using default format string "%Y-%m-%dT%T%Q"
>
> this actually comes from the default format string
> that is defined in old-locale:System.Locale?
>
> iso8601DateFormat :: Maybe String -> String
> iso8601DateFormat mTimeFmt =
> "%Y-%m-%d" ++ case mTimeFmt of
> Nothing -> ""
> Just fmt -> 'T' : fmt
>
> and this can't be right - the 'T' is invalid?
It's very much valid, see [url]http://en.wikipedia.org/wiki/ISO_8601[/url]
/M
--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnusï¼*therning.org Jabber: magnusï¼*therning.org
[url]http://therning.org/magnus[/url] identi.ca|twitter: magthe
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAktrzsYACgkQiMWTaatN+6Qo7QCfeYYiCve18U S2h4Ptpnkx+0zs
tIoAoIbRMhi0zrVM8LTJQf8Iebq61w7j
=4gU7
-----END PGP SIGNATURE----- | 
05-02-10, 11:57 AM
| | | [Haskell-cafe] Re: programmatic DB interface? > and then read with my own parse string:"%Y-%m-%d %T%Q"
> This seems to work just fine.
Thanks. - When I'm using that format string, I get:
Convertible: error converting source data SqlLocalTime 2008-10-29 00:00:00
of type SqlValue to type Data.Time.LocalTime.LocalTime.ZonedTime:
incompatible types
I guess I need to find out who wants ZonedTime.
In my DB description (generated by dbdirect),
the only time-related type is CalendarTime.
J.
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
05-02-10, 02:02 PM
| | | Re: [Haskell-cafe] Re: programmatic DB interface? On Fri, Feb 5, 2010 at 10:55 AM, Johannes Waldmann <
[email]waldmann@imn.htwk-leipzig.de[/email]> wrote:
> > and then read with my own parse string:"%Y-%m-%d %T%Q"
> > This seems to work just fine.
>
> Thanks. - When I'm using that format string, I get:
>
> Convertible: error converting source data SqlLocalTime 2008-10-29 00:00:00
> of type SqlValue to type Data.Time.LocalTime.LocalTime.ZonedTime:
> incompatible types
>
> I guess I need to find out who wants ZonedTime.
>
> In my DB description (generated by dbdirect),
> the only time-related type is CalendarTime.
>
> J.
>
>
> Did you append an empty string in the SELECT statement? If you append the
empty string (||''), HDBC treats the field as text and so returns a
SqlByteString. However, if you do not append the empty string, it treats the
field as a timestamp and tries to convert it before it even reaches your
code.
All of this is just speculation, of course, since I haven't actually looked
at the code. But my "extensive" (ie, 5 minute) testing implies it to be
true.
Michael
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
05-02-10, 03:30 PM
| | | [Haskell-cafe] Re: programmatic DB interface? Michael Snoyman <michael <at> snoyman.com> writes:
> Did you append an empty string in the SELECT statement?
I did not write a SELECT statement (see first post of this thread) ...
SELECTs are generated by haskelldb(-hdbc-postgresql)
I have a working version now, but only by
1. changing the format string computation to
"%Y-%m-%d" ++ ' ' : fmt
2. adding a line in instance Convertible SqlValue ZonedTime
for safeConvert y@(SqlLocalTime x)
Magnus says 1. is wrong, but I don't see how the DB server
could be convinced to send the ...T...Z format.
In my application, the table definition contains 'timestamp without time zone'
and I cannot change that.
J.
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
05-02-10, 03:35 PM
| | | Re: [Haskell-cafe] Re: programmatic DB interface? >>>>> "Johannes" == Johannes Waldmann <waldmann@imn.htwk-leipzig.de> writes:
Johannes> Michael Snoyman <michael <at> snoyman.com> writes:
>> Did you append an empty string in the SELECT statement?
Johannes> Magnus says 1. is wrong, but I don't see how the DB server
Johannes> could be convinced to send the ...T...Z format. In my
Johannes> application, the table definition contains 'timestamp
Johannes> without time zone' and I cannot change that.
That is exactly the problem - it is wrong for CalendarT.
--
Colin Adams
Preston Lancashire
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
05-02-10, 03:52 PM
| | | Re: [Haskell-cafe] Re: programmatic DB interface?
> That is exactly the problem - it is wrong for CalendarT.
what do you mean by "it" ... what package should be fixed
(old-locale, haskelldb-hdbc-postgreqsl, ...)?
Because obviously something seems broken here.
J.
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - [url]http://enigmail.mozdev.org[/url]
iEYEARECAAYFAktsMIsACgkQDqiTJ5Q4dm93RwCdHAXtJDysHA 2hR5JQLKlLk2wm
DDoAn0gcZ0seNtZ7OiYGZdCZ4hm1lMlo
=/APS
-----END PGP SIGNATURE----- | 
05-02-10, 04:10 PM
| | | Re: [Haskell-cafe] Re: programmatic DB interface? >>>>> "Johannes" == Johannes Waldmann <waldmann@imn.htwk-leipzig.de> writes:
>> That is exactly the problem - it is wrong for CalendarT.
Johannes> what do you mean by "it" ... what package should be fixed
Johannes> (old-locale, haskelldb-hdbc-postgreqsl, ...)? Because
Johannes> obviously something seems broken here.
"It" is the use of unzoned times. I sent the following patch to the
haskelldb list several months ago. But there has not been a new release
since then.
Colin> It is just the code to generate the SQL for CREATE TABLE is
Colin> presumably faulty. For CalendarTimeT columns it should
Colin> generate a time of
Colin> timestamp with time zone
Colin> as CalendarTime is a zoned timestamp.
here's my patch:
--- Default.hs~ 2009-02-13 23:06:25.000000000 +0000
+++ Default.hs 2009-10-01 16:43:34.000000000 +0100
@@ -92,7 +92,7 @@
IntegerT -> SqlType "bigint"
DoubleT -> SqlType "double precision"
BoolT -> SqlType "bit"
- CalendarTimeT -> SqlType "timestamp"
+ CalendarTimeT -> SqlType "timestamp with time zone"
BStrT a -> SqlType1 "varchar" a
--
Colin Adams
Preston Lancashire
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url] | 
05-02-10, 04:17 PM
| | | Re: [Haskell-cafe] Re: programmatic DB interface? Colin Paul Adams wrote:
> Colin> It is just the code to generate the SQL for CREATE TABLE is
> Colin> presumably faulty.
well this wouldn't help in my case since I did not CREATE TABLE
from haskelldb. In my application, the DB is given externally,
and I used Database.HaskellDB.DBDirect to create the Haskell interface.
J.
_______________________________________________
Haskell-Cafe mailing list
[email]Haskell-Cafe@haskell.org[/email]
[url]http://www.haskell.org/mailman/listinfo/haskell-cafe[/url]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - [url]http://enigmail.mozdev.org[/url]
iEYEARECAAYFAktsNocACgkQDqiTJ5Q4dm+JCwCeJuAAPLjLnr rX18CmhZpy86wE
ZgAAoMXy9/NPtLlCwFPwIpXfrd+EjHzO
=a0yd
-----END PGP SIGNATURE----- |  | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT +1. The time now is 05:53 PM.
Powered by vBulletin® Version 3.6.8 Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 | |