13. Setup
● 接続情報
val xa = DriverManagerTransactor[Task](
"org.h2.Driver", "url", "user", "password"
)
14. Select
val id = 1
val res =
sql"select * from user where uid = $id"
.query[User]
.unique
.transact(xa)
15. Select
val id = 1
val res =
sql"select * from user where uid = $id"
.query[User]
.unique
.transact(xa)
(注)まだ実行されてないよ!
// Query0[User]
// ConnectionIO[User]
// Task[User]
19. Insert
for {
id <- sql"insert into ...".update
.withUniqueGeneratedKeys[Int]("uid")
_ <- sql"insert into ... values ($id, ...)".update
.run
} yield id
24. YOLO - check
import xa.yolo._
sql"select * from user where uid = $id"
.query[User]
.check
.unsafePerformSync
必要
25. YOLO - check
✓ SQL Compiles and Typechecks
✕ C01 UID INTEGER (INTEGER) NOT NULL → String
- INTEGER (INTEGER) is ostensibly coercible to String according to the JDBC
specification but is not a recommended target type. Fix this by changing the
schema type to CHAR or VARCHAR; or the Scala type to Int or JdbcType.
✓ C02 NAME VARCHAR (VARCHAR) NOT NULL → String
...