Closed katyo closed 10 years ago
Did you try reversing the order of the queryProp
s? E.g.:
fromProps (p_1:p_2:p_3:p_4:p_5:_) =
E.from $ \(e
`E.InnerJoin` p1
`E.InnerJoin` p2
`E.InnerJoin` p3
`E.InnerJoin` p4
`E.InnerJoin` p5) ->
queryProp p_5 e p5 >>
queryProp p_4 e p4 >>
queryProp p_3 e p3 >>
queryProp p_2 e p2 >>
queryProp p_1 e p1 >>
queryEntry e
Hmm, It seems to be working now. Thanks.
Is there any way to do multiple joins like this at runtime?
Yes, if you use implicit inner joins (i.e. independent from
s, joining via where
). Which would work for you since you're using inner joins, but doesn't work in the general case.
I'm going to close this issue then :).
Ok, thanks :)
I have a table
EntryProperty
which implements many-to-many relation betweenEntry
andProperty
.I need to do queries with
INNER JOIN
s between oneEntry
and someEntryProperty
s (zero to five), like this:My first solution looks like so (yesod get request handler):
This works perfect but only with zero and one entry_property. For two and more it throws an sql error:
Esqueleto version is 2.1.1