Skip to content

Commit

Permalink
Fix contains plus isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew de Detrich committed Aug 13, 2019
1 parent 9b4f31e commit 1f57a36
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ class PeopleJdbcSpec extends PeopleSpec {
testContext.run(`Ex 10 page 1 query`) mustEqual `Ex 10 page 1 expected`
testContext.run(`Ex 10 page 2 query`) mustEqual `Ex 10 page 2 expected`
}

"Example 11 - contains + isEmpty" in {
testContext.run(`Ex 11 contains`(`Ex 9 param`)) mustEqual `Ex 9 expected result`
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ trait PeopleSpec extends Spec {
query[Person].filter(p => set.contains(p.age))
}

def `Ex 11 contains`(set: Set[Int]) = quote {
query[Person].filter { p =>
if (liftQuery(set).isEmpty)
true
else
liftQuery(set).contains(p.age)
}
}

val `Ex 8 param` = Set.empty[Int]
val `Ex 8 expected result` = List.empty[Person]

Expand Down

0 comments on commit 1f57a36

Please sign in to comment.