Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add url options to QueryEvaluatorFactory trait apply

  • Loading branch information...
commit b3ab9705df1bec50c2bfa3eee0852c760ecd5b5d 1 parent 2087eec
Matt Freels freels authored
42 src/main/scala/com/twitter/querulous/evaluator/QueryEvaluator.scala
View
@@ -32,24 +32,42 @@ object QueryEvaluator extends QueryEvaluatorFactory {
new StandardQueryEvaluatorFactory(databaseFactory, queryFactory)
}
- def apply(dbhosts: List[String], dbname: String, username: String, password: String) = {
- createEvaluatorFactory()(dbhosts, dbname, username, password)
- }
-
- def apply(dbhosts: List[String], username: String, password: String) = {
- createEvaluatorFactory()(dbhosts, username, password)
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String) = {
+ createEvaluatorFactory()(dbhosts, dbname, username, password, urlOptions)
}
}
trait QueryEvaluatorFactory {
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String): QueryEvaluator
+
+ def apply(dbhost: String, dbname: String, username: String, password: String, urlOptions: String): QueryEvaluator = {
+ apply(List(dbhost), dbname, username, password, urlOptions)
+ }
+
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String): QueryEvaluator = {
+ apply(dbhosts, dbname, username, password, null)
+ }
+
def apply(dbhost: String, dbname: String, username: String, password: String): QueryEvaluator = {
- apply(List(dbhost), dbname, username, password)
+ apply(List(dbhost), dbname, username, password, null)
+ }
+
+ def apply(dbhost: String, username: String, password: String): QueryEvaluator = {
+ apply(List(dbhost), null, username, password, null)
}
- def apply(dbhost: String, username: String, password: String): QueryEvaluator = apply(List(dbhost), username, password)
- def apply(dbhosts: List[String], dbname: String, username: String, password: String): QueryEvaluator
- def apply(dbhosts: List[String], username: String, password: String): QueryEvaluator
- def apply(config: ConfigMap): QueryEvaluator = {
- apply(config.getList("hostname").toList, config("database"), config("username"), config("password"))
+
+ def apply(dbhosts: List[String], username: String, password: String): QueryEvaluator = {
+ apply(dbhosts, null, username, password, null)
+ }
+
+ def apply(config: ConfigMap): QueryEvaluator = {
+ apply(
+ config.getList("hostname").toList,
+ config("database"),
+ config("username"),
+ config("password"),
+ config.getString("url_options").getOrElse(null)
+ )
}
}
3  src/test/scala/com/twitter/querulous/integration/QuerySpec.scala
View
@@ -16,9 +16,10 @@ class QuerySpec extends Specification {
val config = Configgy.config.configMap("db")
val username = config("username")
val password = config("password")
+ val urlOptions = config("url_options")
"Query" should {
- val queryEvaluator = testEvaluatorFactory("localhost", username, password)
+ val queryEvaluator = testEvaluatorFactory("localhost", username, password, urlOptions)
"with too many arguments" >> {
queryEvaluator.select("SELECT 1 FROM DUAL WHERE 1 IN (?)", 1, 2, 3) { r => 1 } must throwA[TooManyQueryParametersException]
5 src/test/scala/com/twitter/querulous/unit/QueryEvaluatorSpec.scala
View
@@ -21,10 +21,11 @@ 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")
"QueryEvaluator" should {
- val queryEvaluator = testEvaluatorFactory("localhost", "db_test", username, password)
- val rootQueryEvaluator = testEvaluatorFactory("localhost", null, username, password)
+ val queryEvaluator = testEvaluatorFactory("localhost", "db_test", username, password, urlOptions)
+ val rootQueryEvaluator = testEvaluatorFactory("localhost", null, username, password, urlOptions)
val queryFactory = new SqlQueryFactory
doBefore {
Please sign in to comment.
Something went wrong with that request. Please try again.