Skip to content

Commit

Permalink
new test for nested exists
Browse files Browse the repository at this point in the history
  • Loading branch information
max-l committed Oct 7, 2012
1 parent 26b19f5 commit e1256e7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/test/scala/org/squeryl/test/schooldb/SchoolDb.scala
Expand Up @@ -1600,6 +1600,30 @@ abstract class SchoolDbTestRun extends SchoolDbTestBase {

}

test("selectFromExists"){
val testInstance = sharedTestInstance; import testInstance._
val qStudents = from(students) ((s) => select(s))
val studentsWithAnAddress =
from(qStudents)(s =>
where(exists(from(addresses)((a) =>
where(s.addressId === a.id) select(a))))
select(s)
)
val qAStudentIfHeHasAnAddress =
from(studentsWithAnAddress)(s =>
where(s.name === "Xiao")
select(s)
)

val res = for (s <- qAStudentIfHeHasAnAddress) yield s.name
val expected = List("Xiao")

assert(expected == res, "expected :\n " + expected + "\ngot : \n " + res)

passed('selectFromExists)

}

test("UpdateSetAll") {
val testInstance = sharedTestInstance; import testInstance._
update(students)(s => setAll(s.age := Some(30)))
Expand Down

0 comments on commit e1256e7

Please sign in to comment.