Skip to content

Commit

Permalink
Add test case for nesting mapped entities
Browse files Browse the repository at this point in the history
  • Loading branch information
cvogt committed Mar 15, 2014
1 parent 0391f06 commit 70a5a2b
Showing 1 changed file with 28 additions and 0 deletions.
Expand Up @@ -154,6 +154,34 @@ class JdbcMapperTest extends TestkitTest[JdbcTestDB] {
assertEquals(oData, ts.first)
}

def testNestedMappedEntity {
case class Part1(i1: Int, i2: String)
case class Part2(i1: String, i2: Int)
case class Whole(p1: Part1, p2: Part2)

class T(tag: Tag) extends Table[Whole](tag, "t_nested") {
def p1 = column[Int]("p1")
def p2 = column[String]("p2")
def p3 = column[String]("p3")
def p4 = column[Int]("p4")
def part1 = (p1,p2) <> (Part1.tupled,Part1.unapply)
def part2 = (p3,p4) <> (Part2.tupled,Part2.unapply)
def * = (part1, part2) <> (Whole.tupled,Whole.unapply)
}
val T = TableQuery[T]

val data = Seq(
Whole(
Part1(1, "2"),
Part2("3", 4)
)
)

T.ddl.create
T.insertAll(data:_*)

assertEquals(data, T.run)
}
def testMappedJoin {
case class A(id: Int, value: Int)
case class B(id: Int, value: Option[String])
Expand Down

0 comments on commit 70a5a2b

Please sign in to comment.