Reputation: 393
In Slick, we can use inSet
for a single column to perform sql IN
clause. But I couldn't figure out how I can use it with pair of columns.
PostgresQL allows the following usage of IN
:
select * from table where (table.a, table.b) in ( values
(1, 'foo'),
(2, 'bar')
)
I thought I can do the following in slick but it doesn't compile:
TableQuery[Table].filter(
row => (row.a, row.b) inSet Seq(
(1, "foo"),
(2, "bar"))
)
Is it possible to make it work?
Upvotes: 1
Views: 361
Reputation: 4501
Now you just can do it manually, writing something like:
val expectedTuples = Seq(
(1, "foo"),
(2, "bar"),
(3, "baz")
)
TableQuery[Table].filter(
row =>
expectedTuples.map{
case(fst, snd) => row.a === fst && row.b === snd
}.reduce(_ || _)
)
This is known feature request in slick.
Upvotes: 1