Closed mwotton closed 10 years ago
Untested, but it should look something like this (basically just a direct translation from what you had to esqueleto):
rows <- select . from $ \(c1, c2, w1, w2) -> do
where_ (c1 ^. ComponentText ==. val "foo"
&&. c2 ^. ComponentText ==. val "bar"
&&. w1 ^. WordComponentComponentId ==. c1 ^. ComponentId
&&. w2 ^. WordComponentComponentId ==. c2 ^. ComponentId
&&. w1 ^. WordComponentWordId ==. w2 ^. WordComponentWordId
&&. w1 ^. WordComponentIndex ==. val 1
&&. w2 ^. WordComponentIndex ==. val 2
)
return (c1 ^. ComponentId, c2 ^. ComponentId)
c2 ^. ComponentId rather than c2 ^ ComponentId, but otherwise perfect. Cheers Erik :)
I might be doing this incorrectly, but I was wondering if there was a way to rename columns in Esqueleto so you can select from them twice in a single query.
As an example, I have some code that selects the two-component phrase ["foo", "bar"] from my db:
Have I missed something, or is this just missing functionality?