From dc853431cfc3207ad7e92bb5755328cd232b8348 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Tue, 21 Nov 2023 13:05:03 +0000 Subject: [PATCH] Fix patch bug --- src/todomvc/item.gleam | 30 +++++++++++++++--------------- src/todomvc/router.gleam | 3 --- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/todomvc/item.gleam b/src/todomvc/item.gleam index 88bd8ac..03796b8 100644 --- a/src/todomvc/item.gleam +++ b/src/todomvc/item.gleam @@ -41,7 +41,7 @@ select from items where - items.user_id = $1 + items.user_id = ?1 group by completed order by @@ -77,7 +77,7 @@ pub fn insert_item( insert into items (content, user_id) values - ($1, $2) + (?1, ?2) returning id " @@ -118,9 +118,9 @@ select from items where - id = $1 + id = ?1 and - user_id = $2 + user_id = ?2 " let assert Ok(rows) = @@ -153,9 +153,9 @@ select from items where - user_id = $1 + user_id = ?1 and - completed = $2 + completed = ?2 order by inserted_at asc " @@ -183,7 +183,7 @@ select from items where - user_id = $1 + user_id = ?1 order by inserted_at asc " @@ -207,9 +207,9 @@ pub fn delete_item(item_id: Int, user_id: Int, db: sqlight.Connection) -> Nil { delete from items where - id = $1 + id = ?1 and - user_id = $2 + user_id = ?2 " let assert Ok(_) = sqlight.query( @@ -234,11 +234,11 @@ pub fn update_item( update items set - content = $3 + content = ?3 where - id = $1 + id = ?1 and - user_id = $2 + user_id = ?2 returning id, completed, @@ -265,7 +265,7 @@ pub fn delete_completed(user_id: Int, db: sqlight.Connection) -> Nil { delete from items where - user_id = $1 + user_id = ?1 and completed = true " @@ -288,9 +288,9 @@ update set completed = not completed where - id = $1 + id = ?1 and - user_id = $2 + user_id = ?2 returning id, completed, diff --git a/src/todomvc/router.gleam b/src/todomvc/router.gleam index 2cba6d4..597ed06 100644 --- a/src/todomvc/router.gleam +++ b/src/todomvc/router.gleam @@ -11,7 +11,6 @@ import todomvc/templates/completed_cleared as completed_cleared_template import todomvc/item.{type Category, Item} import todomvc/web.{type Context} import wisp.{type Request, type Response} -import gleam/io pub fn handle_request(req: Request, ctx: Context) -> Response { let req = wisp.method_override(req) @@ -21,8 +20,6 @@ pub fn handle_request(req: Request, ctx: Context) -> Response { use ctx <- web.authenticate(req, ctx) use <- wisp.serve_static(req, under: "/", from: ctx.static_path) - io.debug(req) - case wisp.path_segments(req) { [] -> home(ctx, item.All) ["active"] -> home(ctx, item.Active)