Permalink
Browse files

failing test for "or + where + whereOpt" edge case, issue #69

  • Loading branch information...
1 parent 1fb8635 commit 20eb9322d1e04cb2a0ca7c85f774cec290f8a730 @ktoso ktoso committed Dec 25, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 rogue-lift/src/test/scala/com/foursquare/rogue/QueryTest.scala
@@ -424,6 +424,17 @@ class QueryTest extends SpecsMatchers {
_.where(_.mayor eqs 2))
.modify(_.userid setTo 1).toString() must_== """db.venues.update({ "$or" : [ { "legid" : 1} , { "mayor" : 2}]}, { "$set" : { "userid" : 1}}, false, false)"""
+ // $or with optional where clause
+ Venue.or(
+ _.where(_.legacyid eqs 1),
+ _.whereOpt(None)(_.mayor eqs _))
+ .modify(_.userid setTo 1).toString() must_== """db.venues.update({ "$or" : [ { "legid" : 1}]}, { "$set" : { "userid" : 1}}, false, false)"""
+
+ Venue.or(
+ _.where(_.legacyid eqs 1),
+ _.whereOpt(Some(2))(_.mayor eqs _))
+ .modify(_.userid setTo 1).toString() must_== """db.venues.update({ "$or" : [ { "legid" : 1} , { "mayor" : 2}]}, { "$set" : { "userid" : 1}}, false, false)"""
+
// OrQuery syntax
val q1 = Venue.where(_.legacyid eqs 1)
val q2 = Venue.where(_.legacyid eqs 2)

0 comments on commit 20eb932

Please sign in to comment.