Created
February 9, 2013 06:18
-
-
Save bleporini/4744161 to your computer and use it in GitHub Desktop.
Scala Slick: Bug on count query generation
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 slick.session.Database | |
import org.scalatest.FunSuite | |
// Use H2Driver to connect to an H2 database | |
import scala.slick.driver.H2Driver.simple._ | |
// Use the implicit threadLocalSession | |
import Database.threadLocalSession | |
/** | |
* @author blep | |
* Date: 09/02/13 | |
* Time: 07:17 | |
*/ | |
class CountBugTest extends FunSuite{ | |
test("count bug"){ | |
object FakeTable extends Table[String]("FAKE"){ | |
def name = column[String]("name") | |
def * = name | |
} | |
Database.forURL("jdbc:h2:mem:countBug","sa","",null,"org.h2.Driver").withSession{ | |
FakeTable.ddl.create | |
val q = for { | |
n <- Parameters[String] | |
u <- FakeTable | |
if u.name is n} yield u.name.count | |
val statement = q.selectStatement | |
println("q.selectStatement = " + statement) | |
assert(! statement.startsWith("select select")) | |
val q2 = for { | |
n <- Parameters[String] | |
u <- FakeTable | |
if u.name is n} yield u.length | |
val statement2 = q2.selectStatement | |
println("q2.selectStatement = " + statement2) | |
assert(! statement2.startsWith("select select")) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment