I think you'd probably want to use the join syntax like:
join(mainTable,
requiredFieldTable1,
requiredFieldTable2,
optionalFieldTable1.leftOuter,
optionalFieldTable2.leftOuter)((main,r1,r2,o1,o2) =>
select(main,o1,o2,r1,r2)
on(main.someId1 === r1.id,
main.someId2 === r2.id,
main.optId1 === o1.map(_.id),
main.optId2 === o2.map(_.id)))
That query should work for you. In the above, it should just return None
for o1
and o2
when the fields do not exist. By using the outerJoin
, Squeryl takes care of the inhibit part for you. You can take a look at this for reference: http://www.squeryl.org/docs/0.9.5/joins.html