🐿️ Type safe SQL in Gleam
716 B
35 lines
1---
2version: 2.0.0
3title: renames arguments to avoid shadowing connection
4file: ./test/squirrel_test.gleam
5test_name: renames_arguments_to_avoid_shadowing_connection_test
6---
7
8import gleam/dynamic/decode
9import pog
10
11pub type QueryRow {
12 QueryRow(connection: Int)
13}
14
15pub fn query(
16 connection: pog.Connection,
17 connection_1: Int,
18) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19 let decoder = {
20 use connection <- decode.field(0, decode.int)
21 decode.success(QueryRow(connection:))
22 }
23
24 "
25with wibble as (select 1 as connection)
26select connection
27from wibble
28where $1 = connection
29"
30 |> pog.query
31 |> pog.parameter(pog.int(connection_1))
32 |> pog.returning(decoder)
33 |> pog.execute(connection)
34}
35