prowdsponsor / esqueleto

Bare bones, type-safe EDSL for SQL queries on persistent backends.
http://hackage.haskell.org/package/esqueleto
BSD 3-Clause "New" or "Revised" License
177 stars 51 forks source link

join on multiple columns (?) #126

Closed JohnFirth closed 8 years ago

JohnFirth commented 8 years ago

Is it possible to write something like the following with Esqueleto? Sorry if I've missed something.

SELECT * FROM table1 INNER JOIN table2 ON table1.column1_name = table2.column1_name AND table1.column2_name = table2.column2_name;

meteficha commented 8 years ago

Yeah, just do something like:

select $
from $ \(t1 `InnerJoin` t2) -> do
on $ t1 ^. Table1Column1 ==. t2 ^. Table2Column1 &&.
     t1 ^. Table1Column2 ==. t2 ^. Table2Column2 
return (t1, t2)