-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
13 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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]'), | ||
|
@@ -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), | ||
|
@@ -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 | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]( | ||
|
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