Created
June 10, 2012 09:54
-
-
Save seratch/2904725 to your computer and use it in GitHub Desktop.
Generalized type constraints in ScalikeJDBC
This file contains hidden or 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
| libraryDependencies ++= Seq( | |
| "com.github.seratch" %% "scalikejdbc" % "1.3.0", | |
| "org.slf4j" % "slf4j-simple" % "1.6.4", | |
| "com.h2database" % "h2" % "[1.3,)" | |
| ) | |
| initialCommands := """import scalikejdbc._ | |
| |Class.forName("org.h2.Driver") | |
| |ConnectionPool.singleton("jdbc:h2:mem:tmp", "", "") | |
| |implicit val session = DB.autoCommitSession | |
| |SQL("create table user (id bigint, name varchar(256))").execute.apply() | |
| |val insert = SQL("insert into user values (?, ?)") | |
| |insert.bind(1, "Alice").update.apply() | |
| |insert.bind(2, "Bob").update.apply() | |
| """.stripMargin | |
| // | |
| // scala> SQL("select * from user").list.apply() | |
| // <console>:12: error: Cannot prove that scalikejdbc.SQL[Nothing,scalikejdbc.NoExtractor] =:= scalikejdbc.SQL[Nothing,scalikejdbc.HasExtractor]. | |
| // SQL("select * from user").list.apply() | |
| // | |
| // scala> SQL("select * from user").map(rs => rs.string("name")).list.apply() | |
| // res2: List[java.lang.String] = List(Alice, Bob) | |
| // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment