slick-pg icon indicating copy to clipboard operation
slick-pg copied to clipboard

Convert Rep[T] to Rep[List[T]]

Open timcharper opened this issue 10 years ago • 4 comments

There presently exists no mechanism to convert a Rep[T] to a Rep[List[T]]; using asColumnOf results in a Postgres error.

Unfortunately, it looks like it will be impossible to get slick to know such a conversion isn't possible at compile time :( But, at least it would be nice to add an implicit toList function to a Rep[T] to convert it accordingly. I think it will require an extension to the Slick query compiler.

timcharper avatar Aug 27 '15 19:08 timcharper

I think I have a pretty good idea how to make this work, but you may no better. I'll wait until your response to work on it.

timcharper avatar Aug 27 '15 19:08 timcharper

Where to use it? In table definition?

tminglei avatar Aug 27 '15 22:08 tminglei

In queries.

Oddly, using ANY does not leverage GIN indices, sadly. In order for it to be used, you need to convert the value to a List, and then do an overlap test.

I had to rewrite a query from ANY to @>, but had a Rep[String]. Ended up going custom SQL on it.

timcharper avatar Aug 27 '15 22:08 timcharper

I see. But I haven't a good idea for it. I'll wait for your solution ^^

tminglei avatar Aug 28 '15 02:08 tminglei