6

When performing filter-joins in Slick, what is the difference under the hood between the following two methods?

val query = for {
 c <- coffees if c.price < 9.0
 s <- c.supplier -- assuming there is a foreign key
} yield (c.name, s.name)

and

val query = for {
 (cof, sup) <- coffees.filter(_.price < 9.0) join supplier on(_.supId === _.id)
} yield (cof.name, sup.name)
Azeli
  • 698
  • 7
  • 16

1 Answers1

8

The first one is an implicit join and the second is an explicit join. Slick generates a WHERE clause for the former like: WHERE c.price < 9 AND c.supId = s.id. However the latter generates a JOIN like JOIN supplier s ON c.supId = s.id. You can have a look at these examples.

ulas
  • 463
  • 5
  • 10
  • Well theres my answer. perhaps i should have asked why you would want to do one vs the other.. – Azeli Feb 11 '16 at 01:05
  • 2
    I think [this](http://stackoverflow.com/questions/44917/explicit-vs-implicit-sql-joins) would be an answer to your question. – ulas Feb 11 '16 at 01:08