Skip to content

Commit

Permalink
Testing transitivity
Browse files Browse the repository at this point in the history
Adding tests for transitivity of bind rewrites.
  • Loading branch information
deusaquilus committed Dec 28, 2016
1 parent 14e0ce5 commit 575f21b
Showing 1 changed file with 22 additions and 8 deletions.
Expand Up @@ -38,25 +38,40 @@ class ThreeWayJoinTest extends AsyncTest[RelationalTestDB] {
}
lazy val ds = TableQuery[D]

def q1 = for {
a <- as
b <- a.bs
d <- b.d
} yield (a, b.id, d)

def q2 = for {
a <- as
b <- a.bs.map(b => b)
d <- b.d
} yield (a, b.id, d)

def q1 = for {
a <- as
b <- a.bs
d <- b.d
} yield (a, b.id, d)
def q3 = for {
a <- as
b <- a.bs.map(b => b).map(b => b)
d <- b.d
} yield (a, b.id, d)

DBIO.seq(
(as.schema ++ bs.schema ++ cs.schema ++ ds.schema).create,
as ++= Seq(1),
ds ++= Seq(3),
bs ++= Seq((2,3)),
cs ++= Seq((1,2)),
q1.result.named("q1").map(_.toSet shouldBe Set((1, 2, 3)))
q1.result.named("q1").map(_.toSet shouldBe Set((1, 2, 3))),
q2.result.named("q2").map(_.toSet shouldBe Set((1, 2, 3))),
q3.result.named("q3").map(_.toSet shouldBe Set((1, 2, 3)))
)
}


// ******************** Many to many join across two tables **********************


// ******************** Many to many join across two tables **********************
def testManyToManyJoinTwice = {
class A(tag: Tag) extends Table[Int](tag, "a_manytomanyjoin2") {
def id = column[Int]("id", O.PrimaryKey)
Expand Down Expand Up @@ -113,5 +128,4 @@ class ThreeWayJoinTest extends AsyncTest[RelationalTestDB] {
)
}


}

0 comments on commit 575f21b

Please sign in to comment.