Using HaskellDB on Tables that contain same column names

Hi all, I'm trying to create a HaskellDB application for keeping the inventory of a set of devices. My database includes some tables which have some columns with same names. Here is an example: Server: id, name, vendor (fk), model(fk), system_id (always null) Vendor: id, name Model: id, name I'm trying to join those three tables and create a result that contains the names of the server, vendor and model. I use the projection: project (Server.name << s!Server.name # Vendor.name << v!Vendor.name # Model.name << m!Model.name # Server.system_id << s!Server.system_id) When I execute the query, the result contains just the name of the servers repeated three times. When I check the generated SQL, I see that it generates not what I expected. Am I missing something here? If you need, I can put the full source & generated SQL to somewhere. -- R. Emre Başar İstanbul Bilgi University Department of Computer Science

I'd recommend sending HaskellDB questions to the haskelldb users
mailing list. You do need to subscribe first. Now to your question:
On Sat, Oct 31, 2009 at 2:38 AM, R. Emre Başar
Hi all, project (Server.name << s!Server.name # Vendor.name << v!Vendor.name # Model.name << m!Model.name # Server.system_id << s!Server.system_id)
This is by design. Just like in SQL, the column names are not disambiguated. If you wrote a SQL query like: select * from Server join Model on ... join Vendor on ... you would get duplicate column names. You must use unique column names in the projection. Check out the haskelldb-th package for Template Haskell utils for easily creating column names if you don't want to declare them by hand. Justin
participants (2)
-
Justin Bailey
-
R. Emre Başar