Permalink
Browse files

Patch out unused operator code, starting to try to lay out an

aggregation dsl
  • Loading branch information...
1 parent 1d86e79 commit d9d1dec51132930b617680a1268d7c84d04fbc0c Brendan W. McAdams committed Oct 24, 2012
@@ -99,7 +99,7 @@ class MongoDBObjectSpec extends CasbahMutableSpecification {
"MongoDBObject Factory & Builder" should {
"Support 'empty', returning a DBObject" in {
- val dbObj = MongoDBObject.empty
+ val dbObj: DBOb = MongoDBObject.empty
dbObj must beDBObject
dbObj must have size (0)
@@ -83,6 +83,7 @@ object QueryExpressionObject {
}
}
+
/**
* Base trait for QueryOperators, children
* are required to define a value for field, which is a String
@@ -112,33 +113,15 @@ trait QueryOperator extends Logging {
*/
protected def op(oper: String, target: Any): DBObject with QueryExpressionObject = QueryExpressionObject(dbObj match {
case Some(nested) => {
- patchSerialization(target)
nested.put(oper, target)
(field -> nested)
}
case None => {
- patchSerialization(target)
val opMap = MongoDBObject(oper -> target)
(field -> opMap)
}
})
- /**
- * Temporary fix code for making sure certain edge cases w/ the serialization libs
- * Don't happen. This may impose a slight performance penalty.
- */
- protected def patchSerialization(target: Any): Unit = target match {
- case _ => {}
- }
-
- def anyListOp(oper: String, target: Any*) =
- if (target.size > 1)
- op(oper, target.toList)
- else if (!target(0).isInstanceOf[Iterable[_]] &&
- !target(0).isInstanceOf[Array[_]])
- op(oper, List(target(0)))
- else op(oper, target(0))
-
}
/**
@@ -65,11 +65,25 @@ class AggregationFrameworkSpec extends CasbahMutableSpecification {
"Aggregation's Group Operator" should {
"Work with field operators" in {
"Allow $first" >> {
- val _group = | $group ("firstAuthor") $first("$author")
+ val _group = | $group "firstAuthor" $first "$author"
_group must not beNull
}
+ "Allow $last" >> {
+ val _group = | $group "lastAuthor" $last "$author"
+ _group must not beNull
+ }
+ "Require $-signs in inner operator fields" >> {
+ lazy val _group = | $group "firstAuthor" $first "author"
+ _group must throwA[IllegalArgumentException]
+ }
+
}
+ "Work with multiple operators" in {
+ val _group = | $group { ("lastAuthor" $last "$author") :: ("firstAuthor" $first "$author") }
+ }
+
+
/*"Require _id" in {
null must beNull
}
View
2 sbt
@@ -4,7 +4,7 @@
# Author: Paul Phillips <paulp@typesafe.com>
# todo - make this dynamic
-declare -r sbt_release_version=0.11.3
+declare -r sbt_release_version=0.12.0
declare -r sbt_snapshot_version=0.13.0-SNAPSHOT
unset sbt_jar sbt_dir sbt_create sbt_snapshot sbt_launch_dir

0 comments on commit d9d1dec

Please sign in to comment.