SELECT DISTINCT in Scala slick -


i using slick 1, , have able apply filter in query lookup entities match condition in related table.

this example using slick documentation shows trying (this contrived example close situation).

here, want coffees provided suppliers on west coast. want coffee only, interested in navigating suppliers apply filter:

val westcoast = seq("ca", "or", "wa") val implicitinnerjoin = {   c <- coffees   s <- suppliers if c.supid === s.id && s.state inset westcoast } yield c 

this works ok, duplicate coffees if there more 1 match in suppliers table.

the obvious workaround in normal sql select distinct; however, cannot find way here.

you in theory a:

query.list.distinct 

after results returned; however, have implemented paging support, wouldn't want process results once come database. here paging support:

query.drop(offset).take(limit).list 

so, in nutshell, need way specify select distinct in query goes out.

anyone have ideas?

as work around can try use groupby:

query.groupby(x=>x).map(_._1) 

it should have same semantics distinct, i'm not sure performance.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -