ScalaQuery requires (AFAIK) to use an provider specific import in your code, for example:
import org.scalaquery.ql.extended.H2Driver.Implicit._
We are trying to use H2 in development mode and MySQL in production. Is there a way to achieve this?
ScalaQuery requires (AFAIK) to use an provider specific import in your code, for example:
import org.scalaquery.ql.extended.H2Driver.Implicit._
We are trying to use H2 in development mode and MySQL in production. Is there a way to achieve this?
My approach was:
class Subscribers(database: Database)(profile: ExtendedProfile) {
import profile.Implicit._
}
Where Subscribers basically is my Data-Access-Object. Not sure this is the best approach out there. It solved my case.
You would create such DAO like:
...in production code:
new Subscribers(database)(MySQLDriver)
...and in test code:
new Subscribers(database)(H2Driver)
I use the following in playframework
object test {
lazy val extendedProfile = {
val extendedProfileName = Play.configuration getString "db.default.extendedProfile" get
companionObjectNamed(extendedProfileName).asInstanceOf[ExtendedProfile]
}
def companionObjectNamed(name: String) : AnyRef = {
val c = Class forName (name + "$")
c.getField("MODULE$") get c
}
}
And then import
import util.extendedProfile.Implicit._
org.scalaquery.ql.extended.MySQLDriver
is the string I used in config to make mysql work.