Skip to content

Commit 42c19d0

Browse files
committed
Restore original parameter name txn
1 parent 9920874 commit 42c19d0

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

cask/src-3.7/cask/database/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package cask
1818
*
1919
* @cask.database.transactional
2020
* @cask.get("/todos")
21-
* def list()(using ctx: Txn) = {
22-
* ctx.run(Todo.select)
21+
* def list()(txn: Txn) = {
22+
* txn.run(Todo.select)
2323
* }
2424
* }}}
2525
*

cask/src-3.7/cask/database/transactional.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import scalasql.core.DbClient
2020
*
2121
* @cask.database.transactional
2222
* @cask.get("/todos")
23-
* def list()(using ctx: Txn) = {
24-
* ctx.run(Todo.select)
23+
* def list()(txn: Txn) = {
24+
* txn.run(Todo.select)
2525
* }
2626
* }}}
2727
*/
2828
class transactional(using dbClient: DbClient) extends RawDecorator {
2929

3030
def wrapFunction(ctx: Request, delegate: Delegate): Result[Raw] = {
3131
dbClient.transaction { txn =>
32-
val result = delegate(ctx, Map("ctx" -> txn))
32+
val result = delegate(ctx, Map("txn" -> txn))
3333

3434
val shouldRollback = result match {
3535
case _: cask.router.Result.Error => true

example/todoDb/app/src/TodoMvcDb.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ object TodoMvcDb extends cask.MainRoutes {
3636

3737
@transactional
3838
@cask.get("/list/:state")
39-
def list(state: String)(using ctx: Txn) = {
39+
def list(state: String)(txn: Txn) = {
4040
val filteredTodos = state match {
41-
case "all" => ctx.run(Todo.select)
42-
case "active" => ctx.run(Todo.select.filter(!_.checked))
43-
case "completed" => ctx.run(Todo.select.filter(_.checked))
41+
case "all" => txn.run(Todo.select)
42+
case "active" => txn.run(Todo.select.filter(!_.checked))
43+
case "completed" => txn.run(Todo.select.filter(_.checked))
4444
}
4545
upickle.default.write(filteredTodos)
4646
}
4747

4848
@transactional
4949
@cask.post("/add")
50-
def add(request: cask.Request)(using ctx: Txn) = {
50+
def add(request: cask.Request)(txn: Txn) = {
5151
val body = request.text()
52-
ctx.run(
52+
txn.run(
5353
Todo
5454
.insert
5555
.columns(_.checked := false, _.text := body)
@@ -62,14 +62,14 @@ object TodoMvcDb extends cask.MainRoutes {
6262

6363
@transactional
6464
@cask.post("/toggle/:index")
65-
def toggle(index: Int)(using ctx: Txn) = {
66-
ctx.run(Todo.update(_.id === index).set(p => p.checked := !p.checked))
65+
def toggle(index: Int)(txn: Txn) = {
66+
txn.run(Todo.update(_.id === index).set(p => p.checked := !p.checked))
6767
}
6868

6969
@transactional
7070
@cask.post("/delete/:index")
71-
def delete(index: Int)(using ctx: Txn) = {
72-
ctx.run(Todo.delete(_.id === index))
71+
def delete(index: Int)(txn: Txn) = {
72+
txn.run(Todo.delete(_.id === index))
7373
}
7474

7575
initialize()

example/todoDbWithLoom/app/src/TodoMvcDbWithLoom.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ object TodoMvcDbWithLoom extends cask.MainRoutes {
4343

4444
@transactional
4545
@cask.get("/list/:state")
46-
def list(state: String)(using ctx: Txn) = {
46+
def list(state: String)(txn: Txn) = {
4747
val filteredTodos = state match {
48-
case "all" => ctx.run(Todo.select)
49-
case "active" => ctx.run(Todo.select.filter(!_.checked))
50-
case "completed" => ctx.run(Todo.select.filter(_.checked))
48+
case "all" => txn.run(Todo.select)
49+
case "active" => txn.run(Todo.select.filter(!_.checked))
50+
case "completed" => txn.run(Todo.select.filter(_.checked))
5151
}
5252
upickle.default.write(filteredTodos)
5353
}
5454

5555
@transactional
5656
@cask.post("/add")
57-
def add(request: cask.Request)(using ctx: Txn) = {
57+
def add(request: cask.Request)(txn: Txn) = {
5858
val body = request.text()
59-
ctx.run(
59+
txn.run(
6060
Todo
6161
.insert
6262
.columns(_.checked := false, _.text := body)
@@ -69,14 +69,14 @@ object TodoMvcDbWithLoom extends cask.MainRoutes {
6969

7070
@transactional
7171
@cask.post("/toggle/:index")
72-
def toggle(index: Int)(using ctx: Txn) = {
73-
ctx.run(Todo.update(_.id === index).set(p => p.checked := !p.checked))
72+
def toggle(index: Int)(txn: Txn) = {
73+
txn.run(Todo.update(_.id === index).set(p => p.checked := !p.checked))
7474
}
7575

7676
@transactional
7777
@cask.post("/delete/:index")
78-
def delete(index: Int)(using ctx: Txn) = {
79-
ctx.run(Todo.delete(_.id === index))
78+
def delete(index: Int)(txn: Txn) = {
79+
txn.run(Todo.delete(_.id === index))
8080
}
8181

8282
initialize()

0 commit comments

Comments
 (0)