Skip to content

Instantly share code, notes, and snippets.

@jmhofer
Created October 25, 2012 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmhofer/3951488 to your computer and use it in GitHub Desktop.
Save jmhofer/3951488 to your computer and use it in GitHub Desktop.
Union Bug in Slick
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))
}
@jmhofer
Copy link
Author

jmhofer commented Oct 25, 2012

Fails to correctly generate the "select" part of the second query within the union.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment