Valent
Valent

Reputation: 75

Slick 3.2.x on unsupported database

Let me refresh already asked question, as the answer there is not clear for newbie. I'm trying to start with Play, Slick 3.2.3 and unsupported database (RDB to be precise). I began from play-scala-isolated-slick-example taken from Play site. RDB database is not supported by Slick, so I tried to use generic Jdbc profile (fit-all as I think):

package test.mydb.slick
import javax.inject.{Inject, Singleton}
import slick.driver.JdbcProfile
import slick.jdbc.JdbcBackend.Database
import test.mydb.{MyTblDAO, Tbl}  // case class defined there
import scala.concurrent.{ExecutionContext, Future}
import scala.language.implicitConversions
import scala.reflect.ClassTag

@Singleton
class SlickMyTblDAO @Inject()(db: Database)(implicit ec: ExecutionContext) 
    extends MyTblDAO with test.mydb.slick.Tables {

//  override val profile: JdbcProfile = _root_.slick.jdbc.JdbcProfile
override val profile: JdbcProfile = slick.driver.JdbcProfile

import profile.api._

def lookup(id: String): Future[Option[MyTbl]] = {....  and so on

This code is not compiled because of:

type mismatch;
[error]  found   : slick.driver.JdbcProfile.type
[error]  required: slick.driver.JdbcProfile
[error]     (which expands to)  slick.jdbc.JdbcProfile
[error]   override val profile: JdbcProfile = slick.driver.JdbcProfile
[error]                                                    ^

Not sure I fully understand the root of the problem, but I guess one can't use Jdbc profile directly. The answer says that "other databases can be supported with a custom implementation of the trait slick.jdbc.JdbcProfile". Does it mean that I need to implement profile myself? Is it achievable for starter? I need just a simple DML, no DDL, no joins for start.

Upvotes: 0

Views: 280

Answers (1)

Zoltán
Zoltán

Reputation: 22176

The error message is telling you that profile needs to extend the trait JdbcProfile, but you're passing it the companion object JdbcProfile, which does not extend the trait of the same name.

To answer your other question - yes, I'm afraid you would have to implement JdbcProfile yourself, and I believe that could be quite a mouthful for a newbie, because Slick's API is quite advanced.

Upvotes: 0

Related Questions