From: Justin B. <jgb...@gm...> - 2008-06-11 21:42:39
|
I think your problem may be the database driver, not haskelldb. What database are you talking to? Can you get any more useful output (try running with "+RTS -xc" option). From the GHC documentation: "-xc (Only available when the program is compiled for profiling.) When an exception is raised in the program, this option causes the current cost-centre-stack to be dumped to stderr. This can be particularly useful for debugging: if your program is complaining about a head [] error and you haven't got a clue which bit of code is causing it, compiling with -prof -auto-all and running with +RTS -xc -RTS will tell you exactly the call stack at the point the error was raised." Justin On Wed, Jun 4, 2008 at 6:10 PM, "Rafael J. Fernández-Moctezuma" <rfe...@cs...> wrote: > Hello everybody! > > I am getting a runtime error when I evaluate aggregates. For example, > consider: > > query1 = do s <- table sailors > project (sid << _sum (s!sid)) > > "sid" is an attribute in table "sailors", of type Int (and NOT NULL). > When evaluating, I get a runtime error: > > user error (The type of sid field can't be converted to SqlUnknown 246 type) > > My intuition is that the type of a sum expression is not necessarily > Int, since you can always sum Doubles. Well, the next obvious step for > me was to rewrite the query and make the "receiving" column type a double: > > data Doublefield = Doublefield > > instance FieldTag Doublefield where fieldName _ = "doublefield" > > doublefield :: Attr Doublefield Double > doublefield = mkAttr Doublefield > > query2 = do s <- table sailors > project (doublefield << _sum (s!sid)) > > > Oops, that won't compile, the inferred type of sum is indeed Int (or so > I'm told by GHC): > > Couldn't match expected type `Double' against inferred type `Int' > Expected type: Expr Double > Inferred type: Expr Int > > Strangely, count, max, and min do work. I wonder if (1) I'm missing > something, or (2) this is indeed an unexpected behaviour (given query1 > passes the typechecker) that may be specific to MySQL... > > Thanks, > > RJFM > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Haskelldb-users mailing list > Has...@li... > https://lists.sourceforge.net/lists/listinfo/haskelldb-users > |