Created
October 25, 2012 08:46
-
-
Save jmhofer/3951488 to your computer and use it in GitHub Desktop.
Union Bug in Slick
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
import scala.slick.driver.ExtendedProfile | |
import scala.slick.driver.H2Driver.simple._ | |
import Database.threadLocalSession | |
abstract class Drinks(tableName: String) extends Table[(Long, Long)](tableName) { | |
def pk = column[Long]("pk") | |
def pkCup = column[Long]("pkCup") | |
def * = pk ~ pkCup | |
} | |
object Coffees extends Drinks("Coffee") | |
object Teas extends Drinks("Tea") | |
object Main extends App { | |
val q1 = for (coffee <- Coffees; tea <- Teas if coffee.pkCup === tea.pkCup) | |
yield coffee.pk ~ coffee.pkCup | |
val q2 = for (coffee <- Coffees; tea <- Teas if coffee.pkCup === tea.pkCup) | |
yield tea.pk ~ tea.pkCup | |
val q3 = q1 union q2 | |
Seq(q1, q2, q3) foreach (q => println(q.selectStatement)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fails to correctly generate the "select" part of the second query within the union.