-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix error introduced in removing existentials (#43)
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ class NestedSpec extends Spec { | |
val emp = Employee(1L, Department(42L, "Brighton"), "[email protected]") | ||
|
||
val action = for { | ||
_ <- emps.schema.drop.asTry | ||
_ <- emps.schema.create | ||
_ <- emps += emp | ||
ans <- emps.result.head | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import slickless.Spec | ||
import shapeless.{HNil, Generic} | ||
import slick.jdbc.H2Profile.api._ | ||
import slickless._ | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
|
||
class Issue42 extends Spec { | ||
|
||
case class Department(id: Long, city: String) | ||
|
||
case class Employee(id: Long, dept1: Department, dept2: Department, email: String) | ||
|
||
class Employees(tag: Tag) extends Table[Employee](tag, "emps42") { | ||
def id = column[Long]("id", O.PrimaryKey, O.AutoInc) | ||
def departmentIdA = column[Long]("dept_a_id") | ||
def departmentCityA = column[String]("dept_a_city") | ||
def departmentIdB = column[Long]("dept_b_id") | ||
def departmentCityB = column[String]("dept_b_city") | ||
def email = column[String]("email") | ||
|
||
def departmentA = (departmentIdA, departmentCityA).mapTo[Department] | ||
def departmentB = (departmentIdB, departmentCityB).mapTo[Department] | ||
|
||
def * = (id :: departmentA :: departmentB :: email :: HNil).mappedWith(Generic[Employee]) | ||
} | ||
|
||
lazy val emps = TableQuery[Employees] | ||
|
||
"slick tables with nested case class mappings" - { | ||
"should support inserts and selects" in { | ||
val db = Database.forConfig("h2") | ||
|
||
val emp = Employee(1L, Department(21L, "Brighton"), Department(22L, "Hove"), "[email protected]") | ||
|
||
val action = for { | ||
_ <- emps.schema.drop.asTry | ||
_ <- emps.schema.create | ||
_ <- emps += emp | ||
ans <- emps.result.head | ||
_ <- emps.schema.drop | ||
} yield ans | ||
|
||
whenReady(db.run(action)) { _ should equal(emp) } | ||
} | ||
} | ||
} |