1
votes

In slick 3 with postgres, I'm trying to use a plain sql query with a tuple column return type. My query is something like this:

sql"""
  select (column1, column2) as tup from table group by tup;
""".as[((Int, String))]

But at compile time I get the following error:

could not find implicit value for parameter rconv: slick.jdbc.GetResult[((Int, String), String)]

How can I return a tuple column type with a plain sql query?

1
Does the query work without the GROUP BY clause? - Dario
@Dario the issue isn't really the group by, it's the mapping between column type and the scala type. The query runs if you run it right on the database with or without the group by, it doesn't run at all through slick. - kag0
Slick doesn't support composite types out of the box, but there is a Slick extension library for PostgreSQL which does. You can see some examples here: github.com/tminglei/slick-pg/blob/… - Yawar

1 Answers

1
votes

GetResult[T] is a wrapper for function PositionedResult => T and expects an implicit val with PositionedResult methods such as nextInt, nextString to extract positional typed fields. The following implicit val should address your need:

implicit val getTableResult = GetResult(r => (r.nextInt, r.nextString))

More details can be found in this Slick doc.