has981
has981

Reputation: 445

Scala Slick compiled query equivalent to "select * from table where word in (words)"

My question is: How can I create a Slick compiled query equivalent to the following SQL:

select * from table where word in ('word1', 'word2', 'word3')

The code I'm currently stuck with looks like this:

val findByWords = Compiled { words: Set[String] =>
  keywords.filter(_.word inSet words)
}

When compiling, I get the following error:

Computation of type Set[String] => slick.lifted.Query[com.company.business.db.CensoredKeyWords,com.company.business.db.CensoredKeyWords#TableElementType,Seq] cannot be compiled (as type C)
val findByWords = Compiled { words: Set[String] =>
                           ^

Notice the arrow is pointing to a curly brace.

I'm using Slick 3.2.1. Scala 2.12.3

Upvotes: 2

Views: 672

Answers (1)

Teimuraz
Teimuraz

Reputation: 9325

It seems like you cannot compile with inSet.

See explanation here: https://groups.google.com/forum/#!msg/scalaquery/2d_r4DEthfY/QqhtrR9mJdcJ

Upvotes: 6

Related Questions