Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add urlOptions to StandardQueryEvaluator and factory

  • Loading branch information...
commit af23ca0956afa91d18c141ebc45918780e8d39a5 1 parent 14f846e
@freels freels authored
View
8 src/main/scala/com/twitter/querulous/evaluator/AutoDisablingQueryEvaluator.scala
@@ -18,12 +18,8 @@ class AutoDisablingQueryEvaluatorFactory(
disableDuration)
}
- def apply(dbhosts: List[String], dbname: String, username: String, password: String) = {
- chainEvaluator(queryEvaluatorFactory(dbhosts, dbname, username, password))
- }
-
- def apply(dbhosts: List[String], username: String, password: String) = {
- chainEvaluator(queryEvaluatorFactory(dbhosts, username, password))
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String) = {
+ chainEvaluator(queryEvaluatorFactory(dbhosts, dbname, username, password, urlOptions))
}
}
View
9 src/main/scala/com/twitter/querulous/evaluator/StandardQueryEvaluator.scala
@@ -10,13 +10,8 @@ class StandardQueryEvaluatorFactory(
databaseFactory: DatabaseFactory,
queryFactory: QueryFactory) extends QueryEvaluatorFactory {
- def apply(dbhosts: List[String], dbname: String, username: String, password: String) = {
- val database = databaseFactory(dbhosts, dbname, username, password)
- new StandardQueryEvaluator(database, queryFactory)
- }
-
- def apply(dbhosts: List[String], username: String, password: String) = {
- val database = databaseFactory(dbhosts, username, password)
+ def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: String) = {
+ val database = databaseFactory(dbhosts, dbname, username, password, urlOptions)
new StandardQueryEvaluator(database, queryFactory)
}
}
View
10 src/test/scala/com/twitter/querulous/integration/QuerySpec.scala
@@ -19,7 +19,7 @@ class QuerySpec extends Specification {
val urlOptions = config("url_options")
"Query" should {
- val queryEvaluator = testEvaluatorFactory("localhost", username, password, urlOptions)
+ val queryEvaluator = testEvaluatorFactory("localhost", null, username, password, urlOptions)
"with too many arguments" >> {
queryEvaluator.select("SELECT 1 FROM DUAL WHERE 1 IN (?)", 1, 2, 3) { r => 1 } must throwA[TooManyQueryParametersException]
@@ -32,5 +32,13 @@ class QuerySpec extends Specification {
"with just the right number of arguments" >> {
queryEvaluator.select("SELECT 1 FROM DUAL WHERE 1 IN (?)", List(1, 2, 3))(_.getInt(1)).toList mustEqual List(1)
}
+
+ "be backwards compatible" >> {
+ val noOpts = testEvaluatorFactory("localhost", null, username, password)
+ noOpts.select("SELECT 1 FROM DUAL WHERE 1 IN (?)", List(1, 2, 3))(_.getInt(1)).toList mustEqual List(1)
+
+ val noDBNameOrOpts = testEvaluatorFactory("localhost", username, password)
+ noDBNameOrOpts.select("SELECT 1 FROM DUAL WHERE 1 IN (?)", List(1, 2, 3))(_.getInt(1)).toList mustEqual List(1)
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.