···
1
1
# CHANGELOG
2
2
3
3
+
## Unreleased
4
4
+
5
5
+
- Squirrel now uses a better name for the generated function connection
6
6
+
parameter.
7
7
+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
8
8
+
3
9
## 4.7.0 - 2026-06-03
4
10
5
11
- Squirrel can now pick some better argument names based on the structure of the
···
524
524
525
525
let #(state, decoder) = decoder_doc(state, constructor_name, returns)
526
526
let #(state, _, args, encoders) = {
527
527
-
// "decoder" and "db" are two arguments that are always defined in the
527
527
+
// "decoder" and "connection" are two arguments that are always defined in the
528
528
// generated function, so we always have them as already used!
529
529
-
let used_names = set.from_list(["decoder", "db"])
529
529
+
let used_names = set.from_list(["decoder", "connection"])
530
530
use acc, param, i <- list.index_fold(params, #(state, used_names, [], []))
531
531
let #(state, used_names, args, encoders) = acc
532
532
···
541
541
}
542
542
543
543
let encoders = list.reverse(encoders)
544
544
-
let args = [doc.from_string("db: pog.Connection"), ..list.reverse(args)]
544
544
+
let args = [
545
545
+
doc.from_string("connection: pog.Connection"),
546
546
+
..list.reverse(args)
547
547
+
]
545
548
546
549
let returned = case returns {
547
550
[] -> doc.from_string("pog.Returned(Nil)")
···
560
563
|> pipe_call_doc("pog.query", _, [])
561
564
|> pipe_all_encoders(encoders)
562
565
|> pipe_call_doc("pog.returning", _, [doc.from_string("decoder")])
563
563
-
|> pipe_call_doc("pog.execute", _, [doc.from_string("db")]),
566
566
+
|> pipe_call_doc("pog.execute", _, [doc.from_string("connection")]),
564
567
]),
565
568
])
566
569
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: array decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: array_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.list(decode.int))
···
23
23
"select array[1, 2, 3] as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: array encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: array_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
array: List(Int),
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.array(fn(value) { pog.int(value) }, array))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: array of names decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: array_of_names_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.list(decode.string))
···
23
23
"select '{}'::name[] as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: array of names encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: array_of_names_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: List(String),
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.array(fn(value) { pog.text(value) }, arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: bool decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: bool_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.bool)
···
23
23
"select true as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: bool encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: bool_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: Bool,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.bool(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: bytea decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: bytea_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.bit_array)
···
23
23
"select 'aaa'::bytea as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: bytea encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: bytea_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: BitArray,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.bytea(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer multiple arguments
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_multiple_arguments_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
squirrel_user_id: Int,
18
18
squirrel_user_name: String,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
···
33
33
|> pog.parameter(pog.int(squirrel_user_id))
34
34
|> pog.parameter(pog.text(squirrel_user_name))
35
35
|> pog.returning(decoder)
36
36
-
|> pog.execute(db)
36
36
+
|> pog.execute(connection)
37
37
}
38
38
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer quoted table access on left of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_quoted_table_access_on_left_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
squirrel_user_special_id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(squirrel_user_special_id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer quoted table access on right of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_quoted_table_access_on_right_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
squirrel_user_special_id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(squirrel_user_special_id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer simple name on left of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_simple_name_on_left_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer simple name on right of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_simple_name_on_right_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer simple quoted name on left of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_simple_quoted_name_on_left_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
squirrel_id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(squirrel_id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer simple quoted name on right of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_simple_quoted_name_on_right_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
squirrel_id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(squirrel_id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer table access on left of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_table_access_on_left_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
squirrel_user_id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(squirrel_user_id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: can infer table access on right of equality
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: can_infer_table_access_on_right_of_equality_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
squirrel_user_id: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
28
28
|> pog.query
29
29
|> pog.parameter(pog.int(squirrel_user_id))
30
30
|> pog.returning(decoder)
31
31
-
|> pog.execute(db)
31
31
+
|> pog.execute(connection)
32
32
}
33
33
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: char decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: char_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.string)
···
23
23
"select 'a'::char as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: char encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: char_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: String,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.text(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: citext decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: citext_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.string)
···
23
23
"select 'wibble'::citext as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: citext encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: citext_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: String,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.text(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: date decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: date_decoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use res <- decode.field(0, pog.calendar_date_decoder())
···
24
24
"select 'Jan-2-1970'::date as res"
25
25
|> pog.query
26
26
|> pog.returning(decoder)
27
27
-
|> pog.execute(db)
27
27
+
|> pog.execute(connection)
28
28
}
29
29
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: date encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: date_encoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
arg_1: Date,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
···
26
26
|> pog.query
27
27
|> pog.parameter(pog.calendar_date(arg_1))
28
28
|> pog.returning(decoder)
29
29
-
|> pog.execute(db)
29
29
+
|> pog.execute(connection)
30
30
}
31
31
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: decode.success with long builder close to 80 chars is properly formatted not breaking it on a different line
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: decode_success_with_long_builder_close_to_80_chars_is_properly_formatted_not_breaking_it_on_a_different_line_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use aaaaaaaa <- decode.field(0, decode.int)
···
35
35
4 as dddddddddddddddd;"
36
36
|> pog.query
37
37
|> pog.returning(decoder)
38
38
-
|> pog.execute(db)
38
38
+
|> pog.execute(connection)
39
39
}
40
40
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: decode.success with long builder is properly formatted not breaking it on a different line
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: decode_success_with_long_builder_is_properly_formatted_not_breaking_it_on_a_different_line_test
···
20
20
}
21
21
22
22
pub fn query(
23
23
-
db: pog.Connection,
23
23
+
connection: pog.Connection,
24
24
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
25
25
let decoder = {
26
26
use first_column <- decode.field(0, decode.int)
···
48
48
6 as sixth_column;"
49
49
|> pog.query
50
50
|> pog.returning(decoder)
51
51
-
|> pog.execute(db)
51
51
+
|> pog.execute(connection)
52
52
}
53
53
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: enum array decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: enum_array_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.list(squirrel_colour_decoder()))
···
23
23
"select array['red'::squirrel_colour] as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
29
29
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: enum decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: enum_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use squirrel_colour <- decode.field(0, squirrel_colour_decoder())
···
23
23
"select 'red'::squirrel_colour"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
29
29
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: enum encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: enum_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: SquirrelColour,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(squirrel_colour_encoder(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
31
31
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: enum with a long enoug name does not generate invalid decoder
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: enum_with_a_long_enoug_name_does_not_generate_invalid_decoder_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use issue_114_aaaaaaaaaaaaaaaaa <- decode.field(
···
26
26
"select 'wibble'::issue_114_aaaaaaaaaaaaaaaaa"
27
27
|> pog.query
28
28
|> pog.returning(decoder)
29
29
-
|> pog.execute(db)
29
29
+
|> pog.execute(connection)
30
30
}
31
31
32
32
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: fields appear in the order they have in the select list
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: fields_appear_in_the_order_they_have_in_the_select_list_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use first <- decode.field(0, decode.bool)
···
25
25
"select true as first, 1 as second, 'wibble' as third"
26
26
|> pog.query
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: float4 decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: float4_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.float)
···
23
23
"select 1.1::float4 as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: float4 encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: float4_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: Float,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.float(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: float8 decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: float8_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.float)
···
23
23
"select 1.1::float8 as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: float8 encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: float8_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: Float,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.float(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: full join columns are optional
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: full_join_columns_are_optional_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use optional1 <- decode.field(0, decode.optional(decode.string))
···
32
32
"
33
33
|> pog.query
34
34
|> pog.returning(decoder)
35
35
-
|> pog.execute(db)
35
35
+
|> pog.execute(connection)
36
36
}
37
37
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: generated type fields are labelled with their name in the select list
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: generated_type_fields_are_labelled_with_their_name_in_the_select_list_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use acorns <- decode.field(0, decode.optional(decode.int))
···
31
31
"
32
32
|> pog.query
33
33
|> pog.returning(decoder)
34
34
-
|> pog.execute(db)
34
34
+
|> pog.execute(connection)
35
35
}
36
36
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: generated type has the same name as the function but in pascal case
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: generated_type_has_the_same_name_as_the_function_but_in_pascal_case_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.bool)
···
25
25
"
26
26
|> pog.query
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: insert with no returned values returns just nil and doesnt define a type
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: insert_with_no_returned_values_returns_just_nil_and_doesnt_define_a_type_test
···
8
8
import gleam/dynamic/decode
9
9
import pog
10
10
11
11
-
pub fn query(db: pog.Connection) -> Result(pog.Returned(Nil), pog.QueryError) {
11
11
+
pub fn query(
12
12
+
connection: pog.Connection,
13
13
+
) -> Result(pog.Returned(Nil), pog.QueryError) {
12
14
let decoder = decode.map(decode.dynamic, fn(_) { Nil })
13
15
14
16
"insert into squirrel values ('sandy', 1000)"
15
17
|> pog.query
16
18
|> pog.returning(decoder)
17
17
-
|> pog.execute(db)
19
19
+
|> pog.execute(connection)
18
20
}
19
21
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: int decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: int_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.int)
···
23
23
"select 11 as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: int encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: int_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.int(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: json decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: json_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.string)
···
23
23
"select '{\"a\": 1}'::json as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: json encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: json_encoding_test
···
10
10
import pog
11
11
12
12
pub fn query(
13
13
-
db: pog.Connection,
13
13
+
connection: pog.Connection,
14
14
arg_1: Json,
15
15
) -> Result(pog.Returned(Nil), pog.QueryError) {
16
16
let decoder = decode.map(decode.dynamic, fn(_) { Nil })
···
19
19
|> pog.query
20
20
|> pog.parameter(pog.text(json.to_string(arg_1)))
21
21
|> pog.returning(decoder)
22
22
-
|> pog.execute(db)
22
22
+
|> pog.execute(connection)
23
23
}
24
24
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: jsonb decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: jsonb_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.string)
···
23
23
"select '{\"a\": 1}'::jsonb as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: jsonb encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: jsonb_encoding_test
···
10
10
import pog
11
11
12
12
pub fn query(
13
13
-
db: pog.Connection,
13
13
+
connection: pog.Connection,
14
14
arg_1: Json,
15
15
) -> Result(pog.Returned(Nil), pog.QueryError) {
16
16
let decoder = decode.map(decode.dynamic, fn(_) { Nil })
···
19
19
|> pog.query
20
20
|> pog.parameter(pog.text(json.to_string(arg_1)))
21
21
|> pog.returning(decoder)
22
22
-
|> pog.execute(db)
22
22
+
|> pog.execute(connection)
23
23
}
24
24
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: left join columns are optional
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: left_join_columns_are_optional_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use not_optional <- decode.field(0, decode.string)
···
32
32
"
33
33
|> pog.query
34
34
|> pog.returning(decoder)
35
35
-
|> pog.execute(db)
35
35
+
|> pog.execute(connection)
36
36
}
37
37
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: left join nullability inference
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: left_join_nullability_inference_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use user_id <- decode.field(0, decode.int)
···
33
33
"
34
34
|> pog.query
35
35
|> pog.returning(decoder)
36
36
-
|> pog.execute(db)
36
36
+
|> pog.execute(connection)
37
37
}
38
38
···
30
30
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
31
31
///
32
32
pub fn query(
33
33
-
db: pog.Connection,
33
33
+
connection: pog.Connection,
34
34
arg_1: SquirrelMood,
35
35
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
36
36
let decoder = {
···
45
45
|> pog.query
46
46
|> pog.parameter(squirrel_mood_encoder(arg_1))
47
47
|> pog.returning(decoder)
48
48
-
|> pog.execute(db)
48
48
+
|> pog.execute(connection)
49
49
}
50
50
51
51
// --- Enums -------------------------------------------------------------------
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: name decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: name_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.string)
···
23
23
"select 'name'::name as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: name encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: name_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: String,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.text(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: nullability with foreign key
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: nullability_with_foreign_key_condition_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
arg_1: Int,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
···
36
36
|> pog.query
37
37
|> pog.parameter(pog.int(arg_1))
38
38
|> pog.returning(decoder)
39
39
-
|> pog.execute(db)
39
39
+
|> pog.execute(connection)
40
40
}
41
41
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: numeric decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: numeric_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, pog.numeric_decoder())
···
23
23
"select 1.1::numeric as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: numeric encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: numeric_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: Float,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.float(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: optional decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: optional_decoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use acorns <- decode.field(0, decode.optional(decode.int))
···
24
24
"select acorns from squirrel"
25
25
|> pog.query
26
26
|> pog.returning(decoder)
27
27
-
|> pog.execute(db)
27
27
+
|> pog.execute(connection)
28
28
}
29
29
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: parameter name keyword is not used in gleam code
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: parameter_name_keyword_is_not_used_in_gleam_code_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
type_: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
30
30
|> pog.query
31
31
|> pog.parameter(pog.int(type_))
32
32
|> pog.returning(decoder)
33
33
-
|> pog.execute(db)
33
33
+
|> pog.execute(connection)
34
34
}
35
35
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: queries are sorted alphabetically
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: queries_are_sorted_alphabetically_test
···
13
13
}
14
14
15
15
pub fn first(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(FirstRow), pog.QueryError) {
18
18
let decoder = {
19
19
use wibble <- decode.field(0, decode.int)
···
23
23
"select 1 as wibble"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
29
29
pub type LastRow {
···
31
31
}
32
32
33
33
pub fn last(
34
34
-
db: pog.Connection,
34
34
+
connection: pog.Connection,
35
35
) -> Result(pog.Returned(LastRow), pog.QueryError) {
36
36
let decoder = {
37
37
use wibble <- decode.field(0, decode.int)
···
41
41
"select 1 as wibble"
42
42
|> pog.query
43
43
|> pog.returning(decoder)
44
44
-
|> pog.execute(db)
44
44
+
|> pog.execute(connection)
45
45
}
46
46
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: query starting with a semicolon does not crash
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: query_starting_with_a_semicolon_does_not_crash_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use result <- decode.field(0, decode.int)
···
23
23
";select 1 as result"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: query that needs more than a single helper function
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: query_that_needs_more_than_a_single_helper_function_test
···
15
15
}
16
16
17
17
pub fn query(
18
18
-
db: pog.Connection,
18
18
+
connection: pog.Connection,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
21
21
use gen_random_uuid <- decode.field(0, uuid_decoder())
···
26
26
"select gen_random_uuid(), 'Jan-2-1970'::date"
27
27
|> pog.query
28
28
|> pog.returning(decoder)
29
29
-
|> pog.execute(db)
29
29
+
|> pog.execute(connection)
30
30
}
31
31
32
32
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: query that needs utils and enums has two sections
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: query_that_needs_utils_and_enums_has_two_sections_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use squirrel_colour <- decode.field(0, squirrel_colour_decoder())
···
25
25
"select 'red'::squirrel_colour, 'Jan-2-1970'::date"
26
26
|> pog.query
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
31
31
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: query with many arguments returning nil
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: query_with_many_arguments_returning_nil_comment_test
···
20
20
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
21
21
///
22
22
pub fn query(
23
23
-
db: pog.Connection,
23
23
+
connection: pog.Connection,
24
24
arg_1: String,
25
25
arg_2: List(String),
26
26
arg_3: List(String),
···
60
60
|> pog.parameter(pog.array(fn(value) { pog.text(value) }, arg_8))
61
61
|> pog.parameter(pog.array(fn(value) { pog.text(value) }, arg_9))
62
62
|> pog.returning(decoder)
63
63
-
|> pog.execute(db)
63
63
+
|> pog.execute(connection)
64
64
}
65
65
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: query with quoted string is properly escaped
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: query_with_quoted_string_is_properly_escaped_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use result <- decode.field(0, decode.int)
···
23
23
"select 1 as \"result\""
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: recursive common table query with semi join
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: recursive_common_table_query_with_semi_join_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
id: Uuid,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
···
42
42
|> pog.query
43
43
|> pog.parameter(pog.text(uuid.to_string(id)))
44
44
|> pog.returning(decoder)
45
45
-
|> pog.execute(db)
45
45
+
|> pog.execute(connection)
46
46
}
47
47
48
48
···
1
1
+
---
2
2
+
version: 2.0.0
3
3
+
title: renames arguments to avoid shadowing connection
4
4
+
file: ./test/squirrel_test.gleam
5
5
+
test_name: renames_arguments_to_avoid_shadowing_connection_test
6
6
+
---
7
7
+
8
8
+
import gleam/dynamic/decode
9
9
+
import pog
10
10
+
11
11
+
pub type QueryRow {
12
12
+
QueryRow(connection: Int)
13
13
+
}
14
14
+
15
15
+
pub fn query(
16
16
+
connection: pog.Connection,
17
17
+
connection_1: Int,
18
18
+
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
+
let decoder = {
20
20
+
use connection <- decode.field(0, decode.int)
21
21
+
decode.success(QueryRow(connection:))
22
22
+
}
23
23
+
24
24
+
"
25
25
+
with wibble as (select 1 as connection)
26
26
+
select connection
27
27
+
from wibble
28
28
+
where $1 = connection
29
29
+
"
30
30
+
|> pog.query
31
31
+
|> pog.parameter(pog.int(connection_1))
32
32
+
|> pog.returning(decoder)
33
33
+
|> pog.execute(connection)
34
34
+
}
35
35
+
···
1
1
-
---
2
2
-
version: 1.5.5
3
3
-
title: renames arguments to avoid shadowing db
4
4
-
file: ./test/squirrel_test.gleam
5
5
-
test_name: renames_arguments_to_avoid_shadowing_db_test
6
6
-
---
7
7
-
8
8
-
import gleam/dynamic/decode
9
9
-
import pog
10
10
-
11
11
-
pub type QueryRow {
12
12
-
QueryRow(db: Int)
13
13
-
}
14
14
-
15
15
-
pub fn query(
16
16
-
db: pog.Connection,
17
17
-
db_1: Int,
18
18
-
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
-
let decoder = {
20
20
-
use db <- decode.field(0, decode.int)
21
21
-
decode.success(QueryRow(db:))
22
22
-
}
23
23
-
24
24
-
"
25
25
-
with wibble as (select 1 as db)
26
26
-
select db
27
27
-
from wibble
28
28
-
where $1 = db
29
29
-
"
30
30
-
|> pog.query
31
31
-
|> pog.parameter(pog.int(db_1))
32
32
-
|> pog.returning(decoder)
33
33
-
|> pog.execute(db)
34
34
-
}
35
35
-
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: renames arguments to avoid shadowing decoder
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: renames_arguments_to_avoid_shadowing_decoder_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
decoder_1: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
30
30
|> pog.query
31
31
|> pog.parameter(pog.int(decoder_1))
32
32
|> pog.returning(decoder)
33
33
-
|> pog.execute(db)
33
33
+
|> pog.execute(connection)
34
34
}
35
35
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: renames arguments to avoid shadowing functions in scope
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: renames_arguments_to_avoid_shadowing_functions_in_scope_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
uuid_decoder_1: Uuid,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
···
31
31
|> pog.query
32
32
|> pog.parameter(pog.text(uuid.to_string(uuid_decoder_1)))
33
33
|> pog.returning(decoder)
34
34
-
|> pog.execute(db)
34
34
+
|> pog.execute(connection)
35
35
}
36
36
37
37
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: renames arguments to avoid two arguments with the same name
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: renames_arguments_to_avoid_two_arguments_with_the_same_name_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
number: Int,
18
18
number_1: Int,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
···
33
33
|> pog.parameter(pog.int(number))
34
34
|> pog.parameter(pog.int(number_1))
35
35
|> pog.returning(decoder)
36
36
-
|> pog.execute(db)
36
36
+
|> pog.execute(connection)
37
37
}
38
38
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: renames arguments to avoid two arguments with the same name 2
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: renames_arguments_to_avoid_two_arguments_with_the_same_name_2_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: Int,
18
18
arg_1_1: Int,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
···
33
33
|> pog.parameter(pog.int(arg_1))
34
34
|> pog.parameter(pog.int(arg_1_1))
35
35
|> pog.returning(decoder)
36
36
-
|> pog.execute(db)
36
36
+
|> pog.execute(connection)
37
37
}
38
38
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: right join columns are optional
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: right_join_columns_are_optional_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use optional <- decode.field(0, decode.optional(decode.string))
···
32
32
"
33
33
|> pog.query
34
34
|> pog.returning(decoder)
35
35
-
|> pog.execute(db)
35
35
+
|> pog.execute(connection)
36
36
}
37
37
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: squirrel supports do blocks
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: squirrel_supports_do_blocks_test
···
8
8
import gleam/dynamic/decode
9
9
import pog
10
10
11
11
-
pub fn query(db: pog.Connection) -> Result(pog.Returned(Nil), pog.QueryError) {
11
11
+
pub fn query(
12
12
+
connection: pog.Connection,
13
13
+
) -> Result(pog.Returned(Nil), pog.QueryError) {
12
14
let decoder = decode.map(decode.dynamic, fn(_) { Nil })
13
15
14
16
"
···
18
20
"
19
21
|> pog.query
20
22
|> pog.returning(decoder)
21
21
-
|> pog.execute(db)
23
23
+
|> pog.execute(connection)
22
24
}
23
25
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: string decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: string_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.string)
···
23
23
"select 'wibble' as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: string encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: string_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: String,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.text(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: strings are ignored when inferring parameters names
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: strings_are_ignored_when_inferring_parameters_names_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
name: String,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
32
32
|> pog.query
33
33
|> pog.parameter(pog.text(name))
34
34
|> pog.returning(decoder)
35
35
-
|> pog.execute(db)
35
35
+
|> pog.execute(connection)
36
36
}
37
37
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: there is only one empty line between code generated for different queries
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: there_is_only_one_empty_line_between_code_generated_for_different_queries_test
···
29
29
/// > 🐿️ This function was generated automatically using v-test of
30
30
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
31
31
///
32
32
-
pub fn one(db: pog.Connection) -> Result(pog.Returned(OneRow), pog.QueryError) {
32
32
+
pub fn one(
33
33
+
connection: pog.Connection,
34
34
+
) -> Result(pog.Returned(OneRow), pog.QueryError) {
33
35
let decoder = {
34
36
use res <- decode.field(0, decode.int)
35
37
decode.success(OneRow(res:))
···
38
40
"select 1 as res"
39
41
|> pog.query
40
42
|> pog.returning(decoder)
41
41
-
|> pog.execute(db)
43
43
+
|> pog.execute(connection)
42
44
}
43
45
44
46
/// A row you get from running the `two` query
···
57
59
/// > 🐿️ This function was generated automatically using v-test of
58
60
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
59
61
///
60
60
-
pub fn two(db: pog.Connection) -> Result(pog.Returned(TwoRow), pog.QueryError) {
62
62
+
pub fn two(
63
63
+
connection: pog.Connection,
64
64
+
) -> Result(pog.Returned(TwoRow), pog.QueryError) {
61
65
let decoder = {
62
66
use res <- decode.field(0, decode.int)
63
67
decode.success(TwoRow(res:))
···
66
70
"select 2 as res"
67
71
|> pog.query
68
72
|> pog.returning(decoder)
69
69
-
|> pog.execute(db)
73
73
+
|> pog.execute(connection)
70
74
}
71
75
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: time decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: time_of_day_decoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use res <- decode.field(0, pog.calendar_time_of_day_decoder())
···
24
24
"select '11:10:01'::time as res"
25
25
|> pog.query
26
26
|> pog.returning(decoder)
27
27
-
|> pog.execute(db)
27
27
+
|> pog.execute(connection)
28
28
}
29
29
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: time encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: time_of_day_encoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
arg_1: TimeOfDay,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
···
26
26
|> pog.query
27
27
|> pog.parameter(pog.calendar_time_of_day(arg_1))
28
28
|> pog.returning(decoder)
29
29
-
|> pog.execute(db)
29
29
+
|> pog.execute(connection)
30
30
}
31
31
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: timestamp decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: timestamp_decoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use res <- decode.field(0, pog.timestamp_decoder())
···
24
24
"select 'Jan-2-1970 12:34:56'::timestamp as res"
25
25
|> pog.query
26
26
|> pog.returning(decoder)
27
27
-
|> pog.execute(db)
27
27
+
|> pog.execute(connection)
28
28
}
29
29
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: timestamp encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: timestamp_encoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
arg_1: Timestamp,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
···
26
26
|> pog.query
27
27
|> pog.parameter(pog.timestamp(arg_1))
28
28
|> pog.returning(decoder)
29
29
-
|> pog.execute(db)
29
29
+
|> pog.execute(connection)
30
30
}
31
31
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: using uuids more than once results in a single uuid decoder helper
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: using_uuids_more_than_once_results_in_a_single_uuid_decoder_helper_test
···
13
13
OneRow(gen_random_uuid: Uuid)
14
14
}
15
15
16
16
-
pub fn one(db: pog.Connection) -> Result(pog.Returned(OneRow), pog.QueryError) {
16
16
+
pub fn one(
17
17
+
connection: pog.Connection,
18
18
+
) -> Result(pog.Returned(OneRow), pog.QueryError) {
17
19
let decoder = {
18
20
use gen_random_uuid <- decode.field(0, uuid_decoder())
19
21
decode.success(OneRow(gen_random_uuid:))
···
22
24
"select gen_random_uuid()"
23
25
|> pog.query
24
26
|> pog.returning(decoder)
25
25
-
|> pog.execute(db)
27
27
+
|> pog.execute(connection)
26
28
}
27
29
28
30
pub type OtherRow {
···
30
32
}
31
33
32
34
pub fn other(
33
33
-
db: pog.Connection,
35
35
+
connection: pog.Connection,
34
36
) -> Result(pog.Returned(OtherRow), pog.QueryError) {
35
37
let decoder = {
36
38
use gen_random_uuid <- decode.field(0, uuid_decoder())
···
40
42
"select gen_random_uuid()"
41
43
|> pog.query
42
44
|> pog.returning(decoder)
43
43
-
|> pog.execute(db)
45
45
+
|> pog.execute(connection)
44
46
}
45
47
46
48
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: uuid decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: uuid_decoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
20
20
use res <- decode.field(0, uuid_decoder())
···
24
24
"select gen_random_uuid() as res"
25
25
|> pog.query
26
26
|> pog.returning(decoder)
27
27
-
|> pog.execute(db)
27
27
+
|> pog.execute(connection)
28
28
}
29
29
30
30
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: uuid encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: uuid_encoding_test
···
14
14
}
15
15
16
16
pub fn query(
17
17
-
db: pog.Connection,
17
17
+
connection: pog.Connection,
18
18
gen_random_uuid: Uuid,
19
19
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
20
20
let decoder = {
···
26
26
|> pog.query
27
27
|> pog.parameter(pog.text(uuid.to_string(gen_random_uuid)))
28
28
|> pog.returning(decoder)
29
29
-
|> pog.execute(db)
29
29
+
|> pog.execute(connection)
30
30
}
31
31
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: varchar decoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: varchar_decoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
18
18
let decoder = {
19
19
use res <- decode.field(0, decode.string)
···
23
23
"select 'wibble'::varchar(6) as res"
24
24
|> pog.query
25
25
|> pog.returning(decoder)
26
26
-
|> pog.execute(db)
26
26
+
|> pog.execute(connection)
27
27
}
28
28
···
1
1
---
2
2
-
version: 1.4.0
2
2
+
version: 2.0.0
3
3
title: varchar encoding
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: varchar_encoding_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
arg_1: String,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
25
25
|> pog.query
26
26
|> pog.parameter(pog.text(arg_1))
27
27
|> pog.returning(decoder)
28
28
-
|> pog.execute(db)
28
28
+
|> pog.execute(connection)
29
29
}
30
30
···
1
1
---
2
2
-
version: 1.5.5
2
2
+
version: 2.0.0
3
3
title: very long argument name is broken when passed as pipeline argument
4
4
file: ./test/squirrel_test.gleam
5
5
test_name: very_long_argument_name_is_broken_when_passed_as_pipeline_argument_test
···
13
13
}
14
14
15
15
pub fn query(
16
16
-
db: pog.Connection,
16
16
+
connection: pog.Connection,
17
17
this_is_a_very_very_very_long_parameter_name_test_aa: Int,
18
18
) -> Result(pog.Returned(QueryRow), pog.QueryError) {
19
19
let decoder = {
···
37
37
pog.int(this_is_a_very_very_very_long_parameter_name_test_aa),
38
38
)
39
39
|> pog.returning(decoder)
40
40
-
|> pog.execute(db)
40
40
+
|> pog.execute(connection)
41
41
}
42
42
···
1082
1082
|> birdie.snap(title: "renames arguments to avoid shadowing decoder")
1083
1083
}
1084
1084
1085
1085
-
pub fn renames_arguments_to_avoid_shadowing_db_test() {
1085
1085
+
pub fn renames_arguments_to_avoid_shadowing_connection_test() {
1086
1086
should_codegen(
1087
1087
"
1088
1088
-
with wibble as (select 1 as db)
1089
1089
-
select db
1088
1088
+
with wibble as (select 1 as connection)
1089
1089
+
select connection
1090
1090
from wibble
1091
1091
-
where $1 = db
1091
1091
+
where $1 = connection
1092
1092
",
1093
1093
)
1094
1094
-
|> birdie.snap(title: "renames arguments to avoid shadowing db")
1094
1094
+
|> birdie.snap(title: "renames arguments to avoid shadowing connection")
1095
1095
}
1096
1096
1097
1097
pub fn renames_arguments_to_avoid_two_arguments_with_the_same_name_test() {