Blob or BYTEA from simple SQL query in Slick 3.0.0
I am trying to return BLOBs from Postgres 9.4 database using Slick 3.0.0
My simple attempt
import slick.driver.PostgresDriver.api._
import slick.jdbc.JdbcBackend.Database
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
object QueryRunner extends App {
val db = Database.forURL("jdbc:postgresql://localhost:5432/test","test_migration","test_migration",driver = "org.postgresql.Driver")
def selectRegions = sql"Select region_data from test.regions".as[java.sql.Blob]
val result = db.run(selectRegions)
val regionData = Await.result(result,1.seconds)}
It brings me back
Error: (16, 65) Could not find implicit rconv parameter value: slick.jdbc.GetResult [java.sql.Blob] def selectRegions = sql "Select region_data from core.regions" .as [java.sql.Blob]
It seems to me that since Blob and BYTEA are somewhat specialized in what I'm missing imports?
source to share
The standard Postgres Slick driver does not currently support Blobs, nor do many other Postgres types. See http://slick.typesafe.com/doc/3.1.0-M1/schemas.html :
The following primitive types are supported out of the box for JDBC-based databases in JdbcProfile (with some limitations on individual database drivers):
Numeric types: Byte, Short, Int, Long, BigDecimal, Float, Double
LOB types: java.sql.Blob, java.sql.Clob, Array [Byte]
Date types: java.sql.Date, java.sql.Time, java.sql.Timestamp
Boolean
Line
Section
java.util.UUID
A community effort has been made to add support for additional types to the modified Postgres driver. You can track the results of these efforts: https://github.com/tminglei/slick-pg .
source to share