Skip to content

Commit

Permalink
Change use DBIO alias type
Browse files Browse the repository at this point in the history
  • Loading branch information
takapi327 committed Dec 24, 2024
1 parent a1f900f commit 2c8318f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions docs/src/main/scala/00-Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import ldbc.dsl.io.*
// #given

// #setupDatabase
val createDatabase: DBIO[IO, Int] =
val createDatabase: DBIO[Int] =
sql"CREATE DATABASE IF NOT EXISTS sandbox_db".update
// #setupDatabase

// #setupUser
val createUser: DBIO[IO, Int] =
val createUser: DBIO[Int] =
sql"""
CREATE TABLE IF NOT EXISTS `user` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Expand All @@ -40,7 +40,7 @@ import ldbc.dsl.io.*
// #setupUser

// #setupProduct
val createProduct: DBIO[IO, Int] =
val createProduct: DBIO[Int] =
sql"""
CREATE TABLE IF NOT EXISTS `product` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Expand All @@ -53,7 +53,7 @@ import ldbc.dsl.io.*
// #setupProduct

// #setupOrder
val createOrder: DBIO[IO, Int] =
val createOrder: DBIO[Int] =
sql"""
CREATE TABLE IF NOT EXISTS `order` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Expand All @@ -70,7 +70,7 @@ import ldbc.dsl.io.*
// #setupOrder

// #insertUser
val insertUser: DBIO[IO, Int] =
val insertUser: DBIO[Int] =
sql"""
INSERT INTO user (name, email) VALUES
('Alice', '[email protected]'),
Expand All @@ -80,7 +80,7 @@ import ldbc.dsl.io.*
// #insertUser

// #insertProduct
val insertProduct: DBIO[IO, Int] =
val insertProduct: DBIO[Int] =
sql"""
INSERT INTO product (name, price) VALUES
('Laptop', 999.99),
Expand All @@ -91,7 +91,7 @@ import ldbc.dsl.io.*
// #insertProduct

// #insertOrder
val insertOrder: DBIO[IO, Int] =
val insertOrder: DBIO[Int] =
sql"""
INSERT INTO `order` (user_id, product_id, quantity) VALUES
(1, 1, 1), -- Alice ordered 1 Laptop
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/scala/01-Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ldbc.dsl.io.*
// #given

// #program
val program: DBIO[IO, Int] = DBIO.pure[IO, Int](1)
val program: DBIO[Int] = DBIO.pure[IO, Int](1)
// #program

// #connection
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/scala/03-Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ldbc.dsl.io.*
// #given

// #program
val program: DBIO[IO, (List[Int], Option[Int], Int)] =
val program: DBIO[(List[Int], Option[Int], Int)] =
for
result1 <- sql"SELECT 1".query[Int].to[List]
result2 <- sql"SELECT 2".query[Int].to[Option]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/scala/04-Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ldbc.dsl.io.*
// #given

// #program
val program: DBIO[IO, Int] =
val program: DBIO[Int] =
sql"INSERT INTO user (name, email) VALUES ('Carol', '[email protected]')".update
// #program

Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/scala/05-Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ import ldbc.dsl.codec.*
case Status.Active => true
case Status.InActive => false

val program1: DBIO[IO, Int] =
val program1: DBIO[Int] =
sql"INSERT INTO user (name, email, status) VALUES (${ "user 1" }, ${ "[email protected]" }, ${ Status.Active })".update

given Decoder.Elem[Status] = Decoder.Elem.mapping[Boolean, Status] {
case true => Status.Active
case false => Status.InActive
}

val program2: DBIO[IO, (String, String, Status)] =
val program2: DBIO[(String, String, Status)] =
sql"SELECT name, email, status FROM user WHERE id = 1".query[(String, String, Status)].unsafe

def connection = Connection[IO](
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/scala/0X-Cleanup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ldbc.dsl.io.*
// #given

// #cleanupDatabase
val dropDatabase: DBIO[IO, Int] =
val dropDatabase: DBIO[Int] =
sql"DROP DATABASE IF EXISTS sandbox_db".update
// #cleanupDatabase

Expand Down

0 comments on commit 2c8318f

Please sign in to comment.