Permalink
Browse files

backwards compatible default url options

  • Loading branch information...
1 parent 4839dc0 commit 15241dbb3f6726666b3c96435e60103ab094467b @freels freels committed Sep 8, 2010
View
@@ -2,7 +2,7 @@ db {
hostname = "localhost"
username = "root"
password = ""
- url_options = {
+ url_options {
useUnicode = "true"
characterEncoding = "UTF-8"
}
@@ -59,7 +59,12 @@ trait Database {
protected def url(dbhosts: List[String], dbname: String, urlOptions: Map[String, String]) = {
val dbnameSegment = if (dbname == null) "" else ("/" + dbname)
- val urlOptsSegment = if (urlOptions == null) "" else ("?" + urlOptions.keys.map( k => k + "=" + urlOptions(k) ).mkString("&"))
+ val urlOptsSegment = if (urlOptions == null) {
+ "?useUnicode=true&characterEncoding=UTF-8"
+ } else {
+ "?" + urlOptions.keys.map( k => k + "=" + urlOptions(k) ).mkString("&")
+ }
+
"jdbc:mysql://" + dbhosts.mkString(",") + dbnameSegment + urlOptsSegment
}
}
@@ -21,7 +21,7 @@ class QueryEvaluatorSpec extends Specification with JMocker with ClassMocker {
val config = Configgy.config.configMap("db")
val username = config("username")
val password = config("password")
- val urlOptions = config("url_options").asInstanceOf[Map[String, String]]
+ val urlOptions = config.configMap("url_options").asMap.asInstanceOf[Map[String, String]]
"QueryEvaluator" should {
val queryEvaluator = testEvaluatorFactory("localhost", "db_test", username, password, urlOptions)

0 comments on commit 15241db

Please sign in to comment.