Skip to content

Commit

Permalink
Fix ReactiveMongo query handling and bump to 1.0.41
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Oct 10, 2016
1 parent 09ddddf commit 9f048ce
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.0.39
## 1.0.39 & 1.0.40

Fix the ReactiveMongo module

Expand Down
2 changes: 1 addition & 1 deletion project/Acolyte.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Acolyte extends Build with Dependencies with Format
jdbcDriver, jdbcScala, jdbcClojure, studio).
settings(
organization in ThisBuild := "org.eu.acolyte",
version in ThisBuild := s"1.0.40${versionVariant}",
version in ThisBuild := s"1.0.41${versionVariant}",
javaOptions in ThisBuild ++= Seq(
"-source", javaVersion, "-target", javaVersion),
scalaVersion in ThisBuild := "2.11.8",
Expand Down
19 changes: 13 additions & 6 deletions reactive-mongo/src/main/scala/Akka.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,26 @@ private[reactivemongo] class Actor(handler: ConnectionHandler)
)
}

case _ Try(handler.queryHandler(cid, req)) match {
case Failure(cause) InvalidQueryHandler(cid, cause.getMessage)
case Request(coln, SimpleBody(ps)) {
val qreq = new Request {
val collection = coln
val body = ps.collectFirst {
case ("$query", q @ BSONDocument(_)) q
}.fold(req.body)(List(_))
}

Try(handler.queryHandler(cid, qreq)) match {
case Failure(cause) InvalidQueryHandler(cid, cause.getMessage)

case Success(res) res.fold(
NoQueryResponse(cid, msg.toString)
)(_ match {
case Success(res) res.fold(NoQueryResponse(cid, msg.toString)) {
case Success(r) r
case Failure(e) MongoDB.QueryError(cid, Option(e.getMessage).
getOrElse(e.getClass.getName)) match {
case Success(err) err
case _ MongoDB.MkQueryError(cid)
}
})
}
}
}
}

Expand Down
14 changes: 8 additions & 6 deletions reactive-mongo/src/test/scala/DriverSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,15 @@ class DriverSpec extends org.specs2.mutable.Specification
"as error when query handler returns no query result" in {
implicit ee: EE
withFlatDriver { implicit drv: MongoDriver
AcolyteDSL.withFlatQueryHandler(
{ _: Request QueryResponse.empty }
) { con: MongoConnection
AcolyteDSL.withFlatCollection(con, query3.collection) {
_.find(query3.body.head).cursor[BSONDocument]().collect[List]()
}
AcolyteDSL.withFlatQueryHandler({
case Request("acolyte.test3", SimpleBody(
("filter", BSONString("valC")) :: Nil)) QueryResponse.empty
}) { con: MongoConnection
AcolyteDSL.withFlatCollection(con, query3.collection) {
_.find(query3.body.head).
cursor[BSONDocument]().collect[List]()
}
}
}.map(_.isEmpty) aka "query result" must beTrue.await(0, timeout)
}

Expand Down
2 changes: 1 addition & 1 deletion site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.eu.acolyte</groupId>
<artifactId>acolyte</artifactId>
<version>1.0.40</version>
<version>1.0.41</version>
<packaging>pom</packaging>
<name>Acolyte</name>

Expand Down
2 changes: 1 addition & 1 deletion studio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<artifactId>studio</artifactId>
<packaging>jar</packaging>
<name>Acolyte Studio</name>
<version>1.0.40</version>
<version>1.0.41</version>
<url>https://github.com/cchantep/acolyte/</url>

<scm>
Expand Down

0 comments on commit 9f048ce

Please sign in to comment.