Permalink
Browse files

Add tests of parentheses-for-union-queries for PostgreSQL too

  • Loading branch information...
kuppuswamy committed Aug 27, 2017
1 parent 4e89890 commit 62e427c71f098f2721d9c745abb2f29b69231a60
@@ -104,6 +104,9 @@ postgres {
DROP TABLESPACE IF EXISTS slick_test
]
driver = org.postgresql.Driver
testClasses = ${testkit.testClasses} [
${testkit.testPackage}.UnionAdditionalTest
]
}
mysql {
@@ -115,7 +118,7 @@ mysql {
drop = DROP DATABASE IF EXISTS ${testDB}
driver = com.mysql.jdbc.Driver
testClasses = ${testkit.testClasses} [
${testkit.testPackage}.MySQLExtraTests
${testkit.testPackage}.UnionAdditionalTest
]
}
@@ -1,12 +1,10 @@
package com.typesafe.slick.testkit.tests
import com.typesafe.slick.testkit.util.{AsyncTest, JdbcTestDB, RelationalTestDB}
import slick.jdbc.MySQLProfile
import com.typesafe.slick.testkit.util.{AsyncTest, JdbcTestDB}
class MySQLExtraTests extends AsyncTest[JdbcTestDB] {
lazy val mysqlProfile = tdb.profile.asInstanceOf[MySQLProfile]
class UnionAdditionalTest extends AsyncTest[JdbcTestDB] {
import mysqlProfile.api._
import tdb.profile.api._
class Managers(tag: Tag) extends Table[(Int, String, String)](tag, "managers") {
def id = column[Int]("id")
@@ -38,14 +36,14 @@ class MySQLExtraTests extends AsyncTest[JdbcTestDB] {
def testLimitWithUnion = {
val q1 = for (m <- managers drop 1 take 2) yield (m.id, m.name)
val q2 = for (e <- employees drop 1 take 3) yield (e.id, e.name)
val q3 = q1 union q2
val q3 = (q1 union q2) sortBy (_._2)
(for {
_ <- (managers.schema ++ employees.schema).create
_ <- managers ++= Seq((1, "Peter", "HR"), (2, "Amy", "IT"), (3, "Steve", "IT"))
_ <- employees ++= Seq((4, "Leonard", 2), (5, "Jennifer", 1), (6, "Tom", 1), (7, "Ben", 1), (8, "Greg", 3))
_ <- mark("q1", q1.result).map(r => r.toSet shouldBe Set((2, "Amy"), (3, "Steve")))
_ <- mark("q2", q2.result).map(r => r.toSet shouldBe Set((5, "Jennifer"), (6, "Tom"), (7, "Ben")))
_ <- mark("q3", q3.result).map(_ shouldBe Vector((2, "Amy"), (3, "Steve"), (5, "Jennifer"), (6, "Tom"), (7, "Ben")))
_ <- mark("q3", q3.result).map(_ shouldBe Vector((2, "Amy"), (7, "Ben"), (5, "Jennifer"), (3, "Steve"), (6, "Tom")))
} yield ()) andFinally (managers.schema ++ employees.schema).drop
}

0 comments on commit 62e427c

Please sign in to comment.