🐿️ Type safe SQL in Gleam
77

Configure Feed

Select the types of activity you want to include in your feed.

add type annotations to the generated code

Giacomo Cavalieri (Aug 25, 2025, 3:40 PM +0200) 06b347d5 cf559a21

+304 -204
+5
CHANGELOG.md
··· 1 1 # CHANGELOG 2 2 3 + ## Unreleased 4 + 5 + - Squirrel now adds type annotations to the generated code. 6 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 7 + 3 8 ## 4.3.0 - 2025-08-22 4 9 5 10 - Added support for the `citext` type.
+4 -3
birdie_snapshots/array_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: array decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: array_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: List(Int)) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.list(decode.int)) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/array_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: array encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: array_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: List(Int)) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/bool_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: bool decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: bool_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/bool_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: bool encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: bool_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: Bool) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/bytea_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: bytea decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: bytea_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: BitArray) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bit_array) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/bytea_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: bytea encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: bytea_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: BitArray) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/char_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: char decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: char_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: String) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.string) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/char_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: char encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: char_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: String) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/citext_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: citext decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: citext_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: String) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.string) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/citext_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: citext encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: citext_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: String) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/date_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: date decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: date_decoding_test ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/time/calendar.{type Date} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(res: Date) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use res <- decode.field(0, pog.calendar_date_decoder()) 19 19 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+5 -3
birdie_snapshots/date_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: date encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: date_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import gleam/time/calendar.{type Date} 10 + import pog.{type Connection} 10 11 11 12 pub type QueryRow { 12 13 QueryRow(res: Bool) 13 14 } 14 15 15 - pub fn query(db, arg_1) { 16 + pub fn query(db: Connection, arg_1: Date) { 16 17 let decoder = { 17 18 use res <- decode.field(0, decode.bool) 18 19 decode.success(QueryRow(res:)) ··· 24 25 |> pog.returning(decoder) 25 26 |> pog.execute(db) 26 27 } 28 +
+4 -3
birdie_snapshots/decode_success_with_long_builder_close_to_80_chars_is_properly_formatted_not_breaking_it_on_a_different_line.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(aaaaaaaa: Int, bbbbbbbbbbbbbbb: Int, ccc: Int, dddddddddddddddd: Int) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use aaaaaaaa <- decode.field(0, decode.int) 18 18 use bbbbbbbbbbbbbbb <- decode.field(1, decode.int) ··· 35 35 |> pog.returning(decoder) 36 36 |> pog.execute(db) 37 37 } 38 +
+4 -3
birdie_snapshots/decode_success_with_long_builder_is_properly_formatted_not_breaking_it_on_a_different_line.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow( ··· 19 19 ) 20 20 } 21 21 22 - pub fn query(db) { 22 + pub fn query(db: Connection) { 23 23 let decoder = { 24 24 use first_column <- decode.field(0, decode.int) 25 25 use second_column <- decode.field(1, decode.int) ··· 48 48 |> pog.returning(decoder) 49 49 |> pog.execute(db) 50 50 } 51 +
+4 -3
birdie_snapshots/enum_array_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: enum array decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: enum_array_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: List(SquirrelColour)) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.list(squirrel_colour_decoder())) 18 18 decode.success(QueryRow(res:)) ··· 40 40 _ -> decode.failure(LightBrown, "SquirrelColour") 41 41 } 42 42 } 43 +
+4 -3
birdie_snapshots/enum_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: enum decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: enum_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(squirrel_colour: SquirrelColour) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use squirrel_colour <- decode.field(0, squirrel_colour_decoder()) 18 18 decode.success(QueryRow(squirrel_colour:)) ··· 40 40 _ -> decode.failure(LightBrown, "SquirrelColour") 41 41 } 42 42 } 43 +
+4 -3
birdie_snapshots/enum_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: enum encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: enum_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Int) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: SquirrelColour) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.int) 18 18 decode.success(QueryRow(res:)) ··· 40 40 } 41 41 |> pog.text 42 42 } 43 +
+4 -3
birdie_snapshots/fields_appear_in_the_order_they_have_in_the_select_list.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(first: Bool, second: Int, third: String) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use first <- decode.field(0, decode.bool) 18 18 use second <- decode.field(1, decode.int) ··· 25 25 |> pog.returning(decoder) 26 26 |> pog.execute(db) 27 27 } 28 +
+4 -3
birdie_snapshots/float4_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: float4 decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: float4_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Float) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.float) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/float4_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: float4 encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: float4_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: Float) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/float8_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: float8 decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: float8_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Float) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.float) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/float8_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: float8 encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: float8_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: Float) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/full_join_columns_are_optional.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/option.{type Option} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(optional1: Option(String), optional2: Option(String)) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use optional1 <- decode.field(0, decode.optional(decode.string)) 19 19 use optional2 <- decode.field(1, decode.optional(decode.string)) ··· 32 32 |> pog.returning(decoder) 33 33 |> pog.execute(db) 34 34 } 35 +
+4 -3
birdie_snapshots/generated_type_fields_are_labelled_with_their_name_in_the_select_list.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/option.{type Option} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(acorns: Option(Int), squirrel_name: String) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use acorns <- decode.field(0, decode.optional(decode.int)) 19 19 use squirrel_name <- decode.field(1, decode.string) ··· 31 31 |> pog.returning(decoder) 32 32 |> pog.execute(db) 33 33 } 34 +
+4 -3
birdie_snapshots/generated_type_has_the_same_name_as_the_function_but_in_pascal_case.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 25 25 |> pog.returning(decoder) 26 26 |> pog.execute(db) 27 27 } 28 +
+4 -3
birdie_snapshots/insert_with_no_returned_values_returns_just_nil_and_doesnt_define_a_type.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 - pub fn query(db) { 11 + pub fn query(db: Connection) { 12 12 let decoder = decode.map(decode.dynamic, fn(_) { Nil }) 13 13 14 14 "insert into squirrel values ('sandy', 1000)" ··· 16 16 |> pog.returning(decoder) 17 17 |> pog.execute(db) 18 18 } 19 +
+4 -3
birdie_snapshots/int_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: int decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: int_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Int) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.int) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/int_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: int encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: int_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: Int) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/json_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: json decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: json_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: String) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.string) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+5 -4
birdie_snapshots/json_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: json encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: json_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import gleam/json 10 - import pog 9 + import gleam/json.{type Json} 10 + import pog.{type Connection} 11 11 12 - pub fn query(db, arg_1) { 12 + pub fn query(db: Connection, arg_1: Json) { 13 13 let decoder = decode.map(decode.dynamic, fn(_) { Nil }) 14 14 15 15 "insert into jsons(json) values ($1)" ··· 18 18 |> pog.returning(decoder) 19 19 |> pog.execute(db) 20 20 } 21 +
+4 -3
birdie_snapshots/jsonb_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: jsonb decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: jsonb_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: String) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.string) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+5 -4
birdie_snapshots/jsonb_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: jsonb encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: jsonb_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import gleam/json 10 - import pog 9 + import gleam/json.{type Json} 10 + import pog.{type Connection} 11 11 12 - pub fn query(db, arg_1) { 12 + pub fn query(db: Connection, arg_1: Json) { 13 13 let decoder = decode.map(decode.dynamic, fn(_) { Nil }) 14 14 15 15 "insert into jsons(jsonb) values($1)" ··· 18 18 |> pog.returning(decoder) 19 19 |> pog.execute(db) 20 20 } 21 +
+4 -3
birdie_snapshots/left_join_columns_are_optional.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/option.{type Option} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(not_optional: String, optional: Option(String)) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use not_optional <- decode.field(0, decode.string) 19 19 use optional <- decode.field(1, decode.optional(decode.string)) ··· 32 32 |> pog.returning(decoder) 33 33 |> pog.execute(db) 34 34 } 35 +
+4 -3
birdie_snapshots/left_join_nullability_inference.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: left join nullability inference 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: left_join_nullability_inference_test ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/option.{type Option} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(user_id: Int, roles: Option(String)) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use user_id <- decode.field(0, decode.int) 19 19 use roles <- decode.field(1, decode.optional(decode.string)) ··· 33 33 |> pog.returning(decoder) 34 34 |> pog.execute(db) 35 35 } 36 +
+4 -3
birdie_snapshots/nullability_with_foreign_key.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/option.{type Option} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(item_id: Int, name: Option(String)) 14 14 } 15 15 16 - pub fn query(db, arg_1) { 16 + pub fn query(db: Connection, arg_1: Int) { 17 17 let decoder = { 18 18 use item_id <- decode.field(0, decode.int) 19 19 use name <- decode.field(1, decode.optional(decode.string)) ··· 35 35 |> pog.returning(decoder) 36 36 |> pog.execute(db) 37 37 } 38 +
+4 -3
birdie_snapshots/numeric_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: numeric decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: numeric_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Float) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, pog.numeric_decoder()) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/numeric_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: numeric encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: numeric_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: Float) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+4 -3
birdie_snapshots/optional_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: optional decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: optional_decoding_test ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/option.{type Option} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(acorns: Option(Int)) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use acorns <- decode.field(0, decode.optional(decode.int)) 19 19 decode.success(QueryRow(acorns:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+5 -4
birdie_snapshots/queries_are_sorted_alphabetically.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: queries are sorted alphabetically 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: queries_are_sorted_alphabetically_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type FirstRow { 12 12 FirstRow(wibble: Int) 13 13 } 14 14 15 - pub fn first(db) { 15 + pub fn first(db: Connection) { 16 16 let decoder = { 17 17 use wibble <- decode.field(0, decode.int) 18 18 decode.success(FirstRow(wibble:)) ··· 28 28 LastRow(wibble: Int) 29 29 } 30 30 31 - pub fn last(db) { 31 + pub fn last(db: Connection) { 32 32 let decoder = { 33 33 use wibble <- decode.field(0, decode.int) 34 34 decode.success(LastRow(wibble:)) ··· 39 39 |> pog.returning(decoder) 40 40 |> pog.execute(db) 41 41 } 42 +
+4 -3
birdie_snapshots/query_starting_with_a_semicolon_does_not_crash.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(result: Int) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use result <- decode.field(0, decode.int) 18 18 decode.success(QueryRow(result:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/query_that_needs_more_than_a_single_helper_function.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/time/calendar.{type Date} 10 - import pog 10 + import pog.{type Connection} 11 11 import youid/uuid.{type Uuid} 12 12 13 13 pub type QueryRow { 14 14 QueryRow(gen_random_uuid: Uuid, date: Date) 15 15 } 16 16 17 - pub fn query(db) { 17 + pub fn query(db: Connection) { 18 18 let decoder = { 19 19 use gen_random_uuid <- decode.field(0, uuid_decoder()) 20 20 use date <- decode.field(1, pog.calendar_date_decoder()) ··· 35 35 Error(_) -> decode.failure(uuid.v7(), "Uuid") 36 36 } 37 37 } 38 +
+4 -3
birdie_snapshots/query_that_needs_utils_and_enums_has_two_sections.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/time/calendar.{type Date} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(squirrel_colour: SquirrelColour, date: Date) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use squirrel_colour <- decode.field(0, squirrel_colour_decoder()) 19 19 use date <- decode.field(1, pog.calendar_date_decoder()) ··· 42 42 _ -> decode.failure(LightBrown, "SquirrelColour") 43 43 } 44 44 } 45 +
+4 -3
birdie_snapshots/query_with_comment.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: query with comment 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: query_with_comment_test ··· 11 11 //// 12 12 13 13 import gleam/dynamic/decode 14 - import pog 14 + import pog.{type Connection} 15 15 16 16 /// A row you get from running the `query` query 17 17 /// defined in `query.sql`. ··· 28 28 /// > 🐿️ This function was generated automatically using v-test of 29 29 /// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). 30 30 /// 31 - pub fn query(db) { 31 + pub fn query(db: Connection) { 32 32 let decoder = { 33 33 use res <- decode.field(0, decode.bool) 34 34 decode.success(QueryRow(res:)) ··· 42 42 |> pog.returning(decoder) 43 43 |> pog.execute(db) 44 44 } 45 +
+15 -3
birdie_snapshots/query_with_many_arguments_returning_nil.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 11 11 //// 12 12 13 13 import gleam/dynamic/decode 14 - import pog 14 + import pog.{type Connection} 15 15 16 16 /// Runs the `query` query 17 17 /// defined in `query.sql`. ··· 19 19 /// > 🐿️ This function was generated automatically using v-test of 20 20 /// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). 21 21 /// 22 - pub fn query(db, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7, arg_8, arg_9) { 22 + pub fn query( 23 + db: Connection, 24 + arg_1: String, 25 + arg_2: List(String), 26 + arg_3: List(String), 27 + arg_4: List(String), 28 + arg_5: List(String), 29 + arg_6: List(String), 30 + arg_7: List(String), 31 + arg_8: List(String), 32 + arg_9: List(String), 33 + ) { 23 34 let decoder = decode.map(decode.dynamic, fn(_) { Nil }) 24 35 25 36 " ··· 51 62 |> pog.returning(decoder) 52 63 |> pog.execute(db) 53 64 } 65 +
+4 -3
birdie_snapshots/query_with_multiline_comment.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: query with multiline comment 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: query_with_multiline_comment_test ··· 11 11 //// 12 12 13 13 import gleam/dynamic/decode 14 - import pog 14 + import pog.{type Connection} 15 15 16 16 /// A row you get from running the `query` query 17 17 /// defined in `query.sql`. ··· 29 29 /// > 🐿️ This function was generated automatically using v-test of 30 30 /// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). 31 31 /// 32 - pub fn query(db) { 32 + pub fn query(db: Connection) { 33 33 let decoder = { 34 34 use res <- decode.field(0, decode.bool) 35 35 decode.success(QueryRow(res:)) ··· 44 44 |> pog.returning(decoder) 45 45 |> pog.execute(db) 46 46 } 47 +
+4 -3
birdie_snapshots/query_with_quoted_string_is_properly_escaped.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(result: Int) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use result <- decode.field(0, decode.int) 18 18 decode.success(QueryRow(result:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/recursive_common_table_query_with_semi_join.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 import youid/uuid.{type Uuid} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(id: Uuid, name: String) 14 14 } 15 15 16 - pub fn query(db, arg_1) { 16 + pub fn query(db: Connection, arg_1: Uuid) { 17 17 let decoder = { 18 18 use id <- decode.field(0, uuid_decoder()) 19 19 use name <- decode.field(1, decode.string) ··· 50 50 Error(_) -> decode.failure(uuid.v7(), "Uuid") 51 51 } 52 52 } 53 +
+4 -3
birdie_snapshots/right_join_columns_are_optional.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/option.{type Option} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(optional: Option(String), not_optional: String) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use optional <- decode.field(0, decode.optional(decode.string)) 19 19 use not_optional <- decode.field(1, decode.string) ··· 32 32 |> pog.returning(decoder) 33 33 |> pog.execute(db) 34 34 } 35 +
+4 -3
birdie_snapshots/squirrel_supports_do_blocks.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: squirrel supports do blocks 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: squirrel_supports_do_blocks_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 - pub fn query(db) { 11 + pub fn query(db: Connection) { 12 12 let decoder = decode.map(decode.dynamic, fn(_) { Nil }) 13 13 14 14 " ··· 20 20 |> pog.returning(decoder) 21 21 |> pog.execute(db) 22 22 } 23 +
+4 -3
birdie_snapshots/string_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: string decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: string_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: String) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.string) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/string_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: string encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: string_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: String) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+5 -4
birdie_snapshots/there_is_only_one_empty_line_between_code_generated_for_different_queries.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 ··· 11 11 //// 12 12 13 13 import gleam/dynamic/decode 14 - import pog 14 + import pog.{type Connection} 15 15 16 16 /// A row you get from running the `one` query 17 17 /// defined in `one.sql`. ··· 29 29 /// > 🐿️ This function was generated automatically using v-test of 30 30 /// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). 31 31 /// 32 - pub fn one(db) { 32 + pub fn one(db: Connection) { 33 33 let decoder = { 34 34 use res <- decode.field(0, decode.int) 35 35 decode.success(OneRow(res:)) ··· 57 57 /// > 🐿️ This function was generated automatically using v-test of 58 58 /// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). 59 59 /// 60 - pub fn two(db) { 60 + pub fn two(db: Connection) { 61 61 let decoder = { 62 62 use res <- decode.field(0, decode.int) 63 63 decode.success(TwoRow(res:)) ··· 68 68 |> pog.returning(decoder) 69 69 |> pog.execute(db) 70 70 } 71 +
+4 -3
birdie_snapshots/time_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: time decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: time_of_day_decoding_test ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/time/calendar.{type TimeOfDay} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(res: TimeOfDay) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use res <- decode.field(0, pog.calendar_time_of_day_decoder()) 19 19 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+5 -3
birdie_snapshots/time_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: time encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: time_of_day_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import gleam/time/calendar.{type TimeOfDay} 10 + import pog.{type Connection} 10 11 11 12 pub type QueryRow { 12 13 QueryRow(res: Bool) 13 14 } 14 15 15 - pub fn query(db, arg_1) { 16 + pub fn query(db: Connection, arg_1: TimeOfDay) { 16 17 let decoder = { 17 18 use res <- decode.field(0, decode.bool) 18 19 decode.success(QueryRow(res:)) ··· 24 25 |> pog.returning(decoder) 25 26 |> pog.execute(db) 26 27 } 28 +
+4 -3
birdie_snapshots/timestamp_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: timestamp decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: timestamp_decoding_test ··· 7 7 8 8 import gleam/dynamic/decode 9 9 import gleam/time/timestamp.{type Timestamp} 10 - import pog 10 + import pog.{type Connection} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(res: Timestamp) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use res <- decode.field(0, pog.timestamp_decoder()) 19 19 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+5 -3
birdie_snapshots/timestamp_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: timestamp encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: timestamp_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import gleam/time/timestamp.{type Timestamp} 10 + import pog.{type Connection} 10 11 11 12 pub type QueryRow { 12 13 QueryRow(res: Bool) 13 14 } 14 15 15 - pub fn query(db, arg_1) { 16 + pub fn query(db: Connection, arg_1: Timestamp) { 16 17 let decoder = { 17 18 use res <- decode.field(0, decode.bool) 18 19 decode.success(QueryRow(res:)) ··· 24 25 |> pog.returning(decoder) 25 26 |> pog.execute(db) 26 27 } 28 +
+5 -4
birdie_snapshots/using_uuids_more_than_once_results_in_a_single_uuid_decoder_helper.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.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 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 import youid/uuid.{type Uuid} 11 11 12 12 pub type OneRow { 13 13 OneRow(gen_random_uuid: Uuid) 14 14 } 15 15 16 - pub fn one(db) { 16 + pub fn one(db: Connection) { 17 17 let decoder = { 18 18 use gen_random_uuid <- decode.field(0, uuid_decoder()) 19 19 decode.success(OneRow(gen_random_uuid:)) ··· 29 29 OtherRow(gen_random_uuid: Uuid) 30 30 } 31 31 32 - pub fn other(db) { 32 + pub fn other(db: Connection) { 33 33 let decoder = { 34 34 use gen_random_uuid <- decode.field(0, uuid_decoder()) 35 35 decode.success(OtherRow(gen_random_uuid:)) ··· 49 49 Error(_) -> decode.failure(uuid.v7(), "Uuid") 50 50 } 51 51 } 52 +
+4 -3
birdie_snapshots/uuid_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: uuid decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: uuid_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 import youid/uuid.{type Uuid} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(res: Uuid) 14 14 } 15 15 16 - pub fn query(db) { 16 + pub fn query(db: Connection) { 17 17 let decoder = { 18 18 use res <- decode.field(0, uuid_decoder()) 19 19 decode.success(QueryRow(res:)) ··· 33 33 Error(_) -> decode.failure(uuid.v7(), "Uuid") 34 34 } 35 35 } 36 +
+5 -4
birdie_snapshots/uuid_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: uuid encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: uuid_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 10 - import youid/uuid 9 + import pog.{type Connection} 10 + import youid/uuid.{type Uuid} 11 11 12 12 pub type QueryRow { 13 13 QueryRow(res: Bool) 14 14 } 15 15 16 - pub fn query(db, arg_1) { 16 + pub fn query(db: Connection, arg_1: Uuid) { 17 17 let decoder = { 18 18 use res <- decode.field(0, decode.bool) 19 19 decode.success(QueryRow(res:)) ··· 25 25 |> pog.returning(decoder) 26 26 |> pog.execute(db) 27 27 } 28 +
+4 -3
birdie_snapshots/varchar_decoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: varchar decoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: varchar_decoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: String) 13 13 } 14 14 15 - pub fn query(db) { 15 + pub fn query(db: Connection) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.string) 18 18 decode.success(QueryRow(res:)) ··· 23 23 |> pog.returning(decoder) 24 24 |> pog.execute(db) 25 25 } 26 +
+4 -3
birdie_snapshots/varchar_encoding.accepted
··· 1 1 --- 2 - version: 1.3.2 2 + version: 1.4.0 3 3 title: varchar encoding 4 4 file: ./test/squirrel_test.gleam 5 5 test_name: varchar_encoding_test 6 6 --- 7 7 8 8 import gleam/dynamic/decode 9 - import pog 9 + import pog.{type Connection} 10 10 11 11 pub type QueryRow { 12 12 QueryRow(res: Bool) 13 13 } 14 14 15 - pub fn query(db, arg_1) { 15 + pub fn query(db: Connection, arg_1: String) { 16 16 let decoder = { 17 17 use res <- decode.field(0, decode.bool) 18 18 decode.success(QueryRow(res:)) ··· 24 24 |> pog.returning(decoder) 25 25 |> pog.execute(db) 26 26 } 27 +
+35 -15
src/squirrel/internal/query.gleam
··· 213 213 ) 214 214 |> import_module("gleam/dynamic/decode") 215 215 |> import_module("pog") 216 + |> import_qualified("pog", "type Connection") 216 217 } 217 218 218 219 fn gleam_type_to_decoder( ··· 309 310 |> string.append("_encoder") 310 311 } 311 312 313 + type TypePosition { 314 + EnumField 315 + FunctionArgument 316 + } 317 + 312 318 fn gleam_type_to_field_type( 313 319 state: CodeGenState, 314 320 type_: gleam.Type, 321 + position: TypePosition, 315 322 ) -> #(CodeGenState, Document) { 316 323 case type_ { 317 324 gleam.List(type_) -> { 318 - let #(state, inner_type) = gleam_type_to_field_type(state, type_) 325 + let #(state, inner_type) = 326 + gleam_type_to_field_type(state, type_, position) 319 327 #(state, call_doc("List", [inner_type])) 320 328 } 321 329 gleam.Option(type_) -> { 322 330 let state = state |> import_qualified("gleam/option", "type Option") 323 - let #(state, inner_type) = gleam_type_to_field_type(state, type_) 331 + let #(state, inner_type) = 332 + gleam_type_to_field_type(state, type_, position) 324 333 #(state, call_doc("Option", [inner_type])) 325 334 } 326 335 gleam.Uuid -> #( ··· 345 354 gleam.Float | gleam.Numeric -> #(state, doc.from_string("Float")) 346 355 gleam.Bool -> #(state, doc.from_string("Bool")) 347 356 gleam.String -> #(state, doc.from_string("String")) 348 - gleam.Json -> #(state, doc.from_string("String")) 357 + gleam.Json -> 358 + case position { 359 + EnumField -> #(state, doc.from_string("String")) 360 + FunctionArgument -> { 361 + let state = state |> import_qualified("gleam/json", "type Json") 362 + #(state, doc.from_string("Json")) 363 + } 364 + } 349 365 gleam.BitArray -> #(state, doc.from_string("BitArray")) 350 366 gleam.Enum(original_name:, name:, variants:) -> #( 351 367 add_enum_helpers(state, original_name, name, variants, NoHelpers), ··· 496 512 Error(_) -> #(state, doc.empty) 497 513 } 498 514 499 - let #(state, inputs, encoders) = { 515 + let #(state, args, encoders) = { 500 516 let acc = #(state, [], []) 501 - use acc, param, i <- list.index_fold(params, acc) 502 - let #(state, inputs, encoders) = acc 517 + use #(state, args, encoders), param, i <- list.index_fold(params, acc) 518 + 519 + let arg = "arg_" <> int.to_string(i + 1) 520 + let #(state, arg_type) = 521 + gleam_type_to_field_type(state, param, FunctionArgument) 522 + let #(state, encoder) = gleam_type_to_encoder(state, param, arg) 503 523 504 - let input = "arg_" <> int.to_string(i + 1) 505 - let #(state, encoder) = gleam_type_to_encoder(state, param, input) 506 - #(state, [input, ..inputs], [encoder, ..encoders]) 524 + let arg = doc.concat([doc.from_string(arg <> ": "), arg_type]) 525 + #(state, [arg, ..args], [encoder, ..encoders]) 507 526 } 508 - let inputs = list.reverse(inputs) 527 + let args = list.reverse(args) 509 528 let encoders = list.reverse(encoders) 510 529 511 530 let #(state, decoder) = decoder_doc(state, constructor_name, returns) 531 + let args = [doc.from_string("db: Connection"), ..args] 512 532 513 533 let code = 514 534 doc.concat([ 515 535 record, 516 536 doc.from_string(function_doc(version, query)), 517 537 doc.line, 518 - fun_doc(Public, gleam.value_identifier_to_string(name), ["db", ..inputs], [ 538 + fun_doc(Public, gleam.value_identifier_to_string(name), args, [ 519 539 let_var("decoder", decoder) |> doc.append(doc.from_string("\n")), 520 540 string_doc(content) 521 541 |> pipe_call_doc("pog.query", _, []) ··· 589 609 use #(state, fields), field <- list.fold(returns, from: #(state, [])) 590 610 let label = 591 611 doc.from_string(gleam.value_identifier_to_string(field.label) <> ": ") 592 - let #(state, field_type) = gleam_type_to_field_type(state, field.type_) 612 + let #(state, field_type) = 613 + gleam_type_to_field_type(state, field.type_, EnumField) 593 614 let field = [label, field_type] |> doc.concat |> doc.group 594 615 595 616 #(state, [field, ..fields]) ··· 713 734 714 735 let case_ = pipe_call_doc("pog.text", case_, []) 715 736 716 - fun_doc(Private, enum_encoder_name(name), [var_name], [case_]) 737 + fun_doc(Private, enum_encoder_name(name), [doc.from_string(var_name)], [case_]) 717 738 } 718 739 719 740 fn enum_decoder_doc( ··· 907 928 fn fun_doc( 908 929 publicity: Publicity, 909 930 name: String, 910 - args: List(String), 931 + args: List(Document), 911 932 body: List(Document), 912 933 ) -> Document { 913 - let args = list.map(args, doc.from_string) 914 934 let publicity = case publicity { 915 935 Private -> "" 916 936 Public -> "pub "