1

When I run next Query, I get nothing sometimes. This hapens when no associated breeder founded for my flower sort.

for {
  sort <- flowerSorts if sort.id === flowerSortId
  sortDetails <- flowersSortDetails if sortDetails.id === flowerSortId
  ftype <- flowerTypes if sort.flowerTypeId === ftype.id
  breeder <- breeders if breeder.id === sort.breederId
  lastBuy <- flowerSortsLastBuy if lastBuy.flowerSortId === flowerSortId
} yield (sort, sortDetails, ftype, breeder, lastBuy)

I`m wondering is it possible to somehow get Option[] for breeder? I try to achive something like:

for {
  sort <- flowerSorts if sort.id === flowerSortId
  sortDetails <- flowersSortDetails if sortDetails.id === flowerSortId
  ftype <- flowerTypes if sort.flowerTypeId === ftype.id
  breeder: Option[_] <- breeders if breeder.id === sort.breederId
  lastBuy: Option[_] <- flowerSortsLastBuy if lastBuy.flowerSortId === flowerSortId
} yield (sort, sortDetails, ftype, breeder, lastBuy)

I know how to achive what I want without For Comprehensions.

  • What you want is an outer join. The documentation (http://slick.lightbend.com/doc/3.1.1/queries.html#joining-and-zipping) doesn't contain an example for monadic outer joins, I don't know if it is possible. It would certainly work with applicative joins. – devkat Aug 09 '16 at 06:32
  • Monadic joins are not possible, as far as I know. How would you write it, `ifMaybe(..` ? xD For [me](http://olivebh.com/scala-play-slick.html), `joinLeft` was more convenient... – insan-e Aug 09 '16 at 07:51

0 Answers0