From: Bjorn B. <d00...@dt...> - 2004-05-04 19:54:17
|
Jeremy Shaw wrote: > I may have discovered a bug in haskelldb. Here is a simplified version > of the what is wrong -- I have not tested to see if the simplified > version actually exhibits the bug. > > Lets say table A has a column 'name' and table B has a column 'name'. > > If I do something like: > > import qualified MyDatabase.A as A > import qualified MyDatabase.B as B > > query = do a <- table A.a > b <- table B.b > project ( A.name << a!A.name # > B.name << b!B.name > ) > > > > If I use the results of the query, b!B.name gets a!A.name's > value[1]. If I change the project to: > > project ( B.name << b!B.name # > A.name << a!A.name > ) > > Then the a!A.name gets b!B.name's value. > > [1] or maybe its the other way around, I don't remember. You are right, it is definitely a bug. And a nasty one too. This HaskellDB code: q = do reports <- table R.d3proj_time_reports users <- table U.d3proj_users project (R.xid << reports!R.xid # U.xid << users!U.xid) Generates this SQL: SELECT DISTINCT id1 as id, id1 as id FROM (SELECT DISTINCT id as id2 FROM d3proj_users as T1) as T1, (SELECT DISTINCT id as id1 FROM d3proj_time_reports as T1) as T2 Of course the driver won't know which "id" field to get the value of. We are not sure how to fix it. Suggestions are welcome. Simply using the fully qualified name everywhere, e.g. "d3proj_time_reports.id" won't work, since you apparantely cannot use that after AS. Thanks for discovering this problem. /Bjorn |