From: Justin B. <jgb...@gm...> - 2009-09-28 17:53:18
|
On Mon, Sep 28, 2009 at 10:20 AM, Colin Paul Adams <co...@co...> wrote: > Not really, as I am not actually requesting that column (not > intentioanlly, anyway). > Probably I have got the project call wrong. My code looks like this: > > let q = do > t <- DB.table IT.imageTable > DB.project (IT.indexNumber DB.<< t DB.! IT.indexNumber) > DB.order [DB.desc t IT.indexNumber] > return t > rs <- DB.query db q > let nextIndex = case null rs of > True -> 1 > False -> 1 + (head rs DB.! IT.indexNumber) > Rewrite your projection so you aren't returning t: > let q = do > t <- DB.table IT.imageTable > DB.order [DB.desc t IT.indexNumber] > DB.project (IT.indexNumber DB.<< t DB.! IT.indexNumber) Returning "t" projected every column in the table, which led to the conversion problem. DB.project should always be the last function called, as it filters the columns returned down to just the ones you want. I moved the order call above the project call so you can still get your results ordered like you want, but it doesn't interfere with the projection. If you ever need to look at the actual SQL generated, you can use showQuery. Does that do the trick? Justin |