From fb364cebbbbf98a964da87111668aaa4e11e140f Mon Sep 17 00:00:00 2001 From: Giacomo Cavalieri Date: Wed, 30 Jul 2025 17:50:51 +0200 Subject: [PATCH 1/3] add module doc comment to the generated modules --- CHANGELOG.md | 7 ++++++ birdie_snapshots/array_decoding.accepted | 9 ++++++- birdie_snapshots/array_encoding.accepted | 9 ++++++- birdie_snapshots/bool_decoding.accepted | 9 ++++++- birdie_snapshots/bool_encoding.accepted | 9 ++++++- birdie_snapshots/bytea_decoding.accepted | 9 ++++++- birdie_snapshots/bytea_encoding.accepted | 9 ++++++- birdie_snapshots/char_decoding.accepted | 9 ++++++- birdie_snapshots/char_encoding.accepted | 9 ++++++- birdie_snapshots/date_decoding.accepted | 9 ++++++- birdie_snapshots/date_encoding.accepted | 9 ++++++- ...t_breaking_it_on_a_different_line.accepted | 9 ++++++- ...t_breaking_it_on_a_different_line.accepted | 9 ++++++- birdie_snapshots/enum_array_decoding.accepted | 9 ++++++- birdie_snapshots/enum_decoding.accepted | 9 ++++++- birdie_snapshots/enum_encoding.accepted | 9 ++++++- ...rder_they_have_in_the_select_list.accepted | 9 ++++++- birdie_snapshots/float4_decoding.accepted | 9 ++++++- birdie_snapshots/float4_encoding.accepted | 9 ++++++- birdie_snapshots/float8_decoding.accepted | 9 ++++++- birdie_snapshots/float8_encoding.accepted | 9 ++++++- .../full_join_columns_are_optional.accepted | 9 ++++++- ...ith_their_name_in_the_select_list.accepted | 9 ++++++- ...s_the_function_but_in_pascal_case.accepted | 9 ++++++- ...just_nil_and_doesnt_define_a_type.accepted | 9 ++++++- birdie_snapshots/int_decoding.accepted | 9 ++++++- birdie_snapshots/int_encoding.accepted | 9 ++++++- birdie_snapshots/json_decoding.accepted | 9 ++++++- birdie_snapshots/json_encoding.accepted | 9 ++++++- birdie_snapshots/jsonb_decoding.accepted | 9 ++++++- birdie_snapshots/jsonb_encoding.accepted | 9 ++++++- .../left_join_columns_are_optional.accepted | 9 ++++++- .../left_join_nullability_inference.accepted | 9 ++++++- .../nullability_with_foreign_key.accepted | 9 ++++++- birdie_snapshots/numeric_decoding.accepted | 9 ++++++- birdie_snapshots/numeric_encoding.accepted | 9 ++++++- birdie_snapshots/optional_decoding.accepted | 9 ++++++- ...queries_are_sorted_alphabetically.accepted | 7 ++++++ ...g_with_a_semicolon_does_not_crash.accepted | 7 ++++++ ...ore_than_a_single_helper_function.accepted | 9 ++++++- ..._utils_and_enums_has_two_sections.accepted | 9 ++++++- birdie_snapshots/query_with_comment.accepted | 9 ++++++- .../query_with_multiline_comment.accepted | 9 ++++++- ...quoted_string_is_properly_escaped.accepted | 9 ++++++- ...common_table_query_with_semi_join.accepted | 9 ++++++- .../right_join_columns_are_optional.accepted | 9 ++++++- .../squirrel_supports_do_blocks.accepted | 7 ++++++ birdie_snapshots/string_decoding.accepted | 9 ++++++- birdie_snapshots/string_encoding.accepted | 9 ++++++- ...e_generated_for_different_queries.accepted | 9 ++++++- birdie_snapshots/time_decoding.accepted | 9 ++++++- birdie_snapshots/time_encoding.accepted | 9 ++++++- birdie_snapshots/timestamp_decoding.accepted | 9 ++++++- birdie_snapshots/timestamp_encoding.accepted | 9 ++++++- ...s_in_a_single_uuid_decoder_helper.accepted | 9 ++++++- birdie_snapshots/uuid_decoding.accepted | 9 ++++++- birdie_snapshots/uuid_encoding.accepted | 9 ++++++- birdie_snapshots/varchar_decoding.accepted | 9 ++++++- birdie_snapshots/varchar_encoding.accepted | 9 ++++++- src/squirrel.gleam | 12 +++++++--- src/squirrel/internal/query.gleam | 24 ++++++++++++++++--- test/squirrel_test.gleam | 2 +- 62 files changed, 499 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2951348..97a7c9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CHANGELOG +## Unreleased + +- Squirrel will now include a doc comment at the beginning of each generated + module, explaining where the queries come from and what version of squirrel + was used to generate the code. + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) + ## 4.1.0 - 2025-07-28 - Squirrel will now pick files under a project's `test` and `dev` directories. diff --git a/birdie_snapshots/array_decoding.accepted b/birdie_snapshots/array_decoding.accepted index 733a461..4c9ceaf 100644 --- a/birdie_snapshots/array_decoding.accepted +++ b/birdie_snapshots/array_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: array decoding file: ./test/squirrel_test.gleam test_name: array_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/array_encoding.accepted b/birdie_snapshots/array_encoding.accepted index 4a3d127..5bb8f83 100644 --- a/birdie_snapshots/array_encoding.accepted +++ b/birdie_snapshots/array_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: array encoding file: ./test/squirrel_test.gleam test_name: array_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/bool_decoding.accepted b/birdie_snapshots/bool_decoding.accepted index d845fc6..ff4107f 100644 --- a/birdie_snapshots/bool_decoding.accepted +++ b/birdie_snapshots/bool_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: bool decoding file: ./test/squirrel_test.gleam test_name: bool_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/bool_encoding.accepted b/birdie_snapshots/bool_encoding.accepted index f900f04..4a67545 100644 --- a/birdie_snapshots/bool_encoding.accepted +++ b/birdie_snapshots/bool_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: bool encoding file: ./test/squirrel_test.gleam test_name: bool_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/bytea_decoding.accepted b/birdie_snapshots/bytea_decoding.accepted index 16c3ccd..414e7c1 100644 --- a/birdie_snapshots/bytea_decoding.accepted +++ b/birdie_snapshots/bytea_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: bytea decoding file: ./test/squirrel_test.gleam test_name: bytea_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/bytea_encoding.accepted b/birdie_snapshots/bytea_encoding.accepted index 67d1dfd..4a8e822 100644 --- a/birdie_snapshots/bytea_encoding.accepted +++ b/birdie_snapshots/bytea_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: bytea encoding file: ./test/squirrel_test.gleam test_name: bytea_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/char_decoding.accepted b/birdie_snapshots/char_decoding.accepted index 2a85c52..e96daba 100644 --- a/birdie_snapshots/char_decoding.accepted +++ b/birdie_snapshots/char_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: char decoding file: ./test/squirrel_test.gleam test_name: char_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/char_encoding.accepted b/birdie_snapshots/char_encoding.accepted index cd81239..9bd0e97 100644 --- a/birdie_snapshots/char_encoding.accepted +++ b/birdie_snapshots/char_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: char encoding file: ./test/squirrel_test.gleam test_name: char_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/date_decoding.accepted b/birdie_snapshots/date_decoding.accepted index 7dea757..a540665 100644 --- a/birdie_snapshots/date_decoding.accepted +++ b/birdie_snapshots/date_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: date decoding file: ./test/squirrel_test.gleam test_name: date_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/time/calendar.{type Date} import pog diff --git a/birdie_snapshots/date_encoding.accepted b/birdie_snapshots/date_encoding.accepted index 58bd39e..f56cb5f 100644 --- a/birdie_snapshots/date_encoding.accepted +++ b/birdie_snapshots/date_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: date encoding file: ./test/squirrel_test.gleam test_name: date_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/decode_success_with_long_builder_close_to_80_chars_is_properly_formatted_not_breaking_it_on_a_different_line.accepted b/birdie_snapshots/decode_success_with_long_builder_close_to_80_chars_is_properly_formatted_not_breaking_it_on_a_different_line.accepted index 917743c..822e025 100644 --- a/birdie_snapshots/decode_success_with_long_builder_close_to_80_chars_is_properly_formatted_not_breaking_it_on_a_different_line.accepted +++ b/birdie_snapshots/decode_success_with_long_builder_close_to_80_chars_is_properly_formatted_not_breaking_it_on_a_different_line.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: decode.success with long builder close to 80 chars is properly formatted not breaking it on a different line file: ./test/squirrel_test.gleam test_name: decode_success_with_long_builder_close_to_80_chars_is_properly_formatted_not_breaking_it_on_a_different_line_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/decode_success_with_long_builder_is_properly_formatted_not_breaking_it_on_a_different_line.accepted b/birdie_snapshots/decode_success_with_long_builder_is_properly_formatted_not_breaking_it_on_a_different_line.accepted index f4d89a9..338c7ac 100644 --- a/birdie_snapshots/decode_success_with_long_builder_is_properly_formatted_not_breaking_it_on_a_different_line.accepted +++ b/birdie_snapshots/decode_success_with_long_builder_is_properly_formatted_not_breaking_it_on_a_different_line.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: decode.success with long builder is properly formatted not breaking it on a different line file: ./test/squirrel_test.gleam test_name: decode_success_with_long_builder_is_properly_formatted_not_breaking_it_on_a_different_line_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/enum_array_decoding.accepted b/birdie_snapshots/enum_array_decoding.accepted index f9ec373..495cf95 100644 --- a/birdie_snapshots/enum_array_decoding.accepted +++ b/birdie_snapshots/enum_array_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: enum array decoding file: ./test/squirrel_test.gleam test_name: enum_array_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/enum_decoding.accepted b/birdie_snapshots/enum_decoding.accepted index 13cf60e..c043d5a 100644 --- a/birdie_snapshots/enum_decoding.accepted +++ b/birdie_snapshots/enum_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: enum decoding file: ./test/squirrel_test.gleam test_name: enum_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/enum_encoding.accepted b/birdie_snapshots/enum_encoding.accepted index 9d9b9a9..945a3d5 100644 --- a/birdie_snapshots/enum_encoding.accepted +++ b/birdie_snapshots/enum_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: enum encoding file: ./test/squirrel_test.gleam test_name: enum_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/fields_appear_in_the_order_they_have_in_the_select_list.accepted b/birdie_snapshots/fields_appear_in_the_order_they_have_in_the_select_list.accepted index 6c74e94..9966c2d 100644 --- a/birdie_snapshots/fields_appear_in_the_order_they_have_in_the_select_list.accepted +++ b/birdie_snapshots/fields_appear_in_the_order_they_have_in_the_select_list.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: fields appear in the order they have in the select list file: ./test/squirrel_test.gleam test_name: fields_appear_in_the_order_they_have_in_the_select_list_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/float4_decoding.accepted b/birdie_snapshots/float4_decoding.accepted index 5b4a988..c0b6e84 100644 --- a/birdie_snapshots/float4_decoding.accepted +++ b/birdie_snapshots/float4_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: float4 decoding file: ./test/squirrel_test.gleam test_name: float4_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/float4_encoding.accepted b/birdie_snapshots/float4_encoding.accepted index bbe09b7..fce85ad 100644 --- a/birdie_snapshots/float4_encoding.accepted +++ b/birdie_snapshots/float4_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: float4 encoding file: ./test/squirrel_test.gleam test_name: float4_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/float8_decoding.accepted b/birdie_snapshots/float8_decoding.accepted index 26cddeb..eeb0753 100644 --- a/birdie_snapshots/float8_decoding.accepted +++ b/birdie_snapshots/float8_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: float8 decoding file: ./test/squirrel_test.gleam test_name: float8_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/float8_encoding.accepted b/birdie_snapshots/float8_encoding.accepted index f7935cf..333a522 100644 --- a/birdie_snapshots/float8_encoding.accepted +++ b/birdie_snapshots/float8_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: float8 encoding file: ./test/squirrel_test.gleam test_name: float8_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/full_join_columns_are_optional.accepted b/birdie_snapshots/full_join_columns_are_optional.accepted index 918b15a..3689d6c 100644 --- a/birdie_snapshots/full_join_columns_are_optional.accepted +++ b/birdie_snapshots/full_join_columns_are_optional.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: full join columns are optional file: ./test/squirrel_test.gleam test_name: full_join_columns_are_optional_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/option.{type Option} import pog diff --git a/birdie_snapshots/generated_type_fields_are_labelled_with_their_name_in_the_select_list.accepted b/birdie_snapshots/generated_type_fields_are_labelled_with_their_name_in_the_select_list.accepted index cee1cc6..92c0f6a 100644 --- a/birdie_snapshots/generated_type_fields_are_labelled_with_their_name_in_the_select_list.accepted +++ b/birdie_snapshots/generated_type_fields_are_labelled_with_their_name_in_the_select_list.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: generated type fields are labelled with their name in the select list file: ./test/squirrel_test.gleam test_name: generated_type_fields_are_labelled_with_their_name_in_the_select_list_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/option.{type Option} import pog diff --git a/birdie_snapshots/generated_type_has_the_same_name_as_the_function_but_in_pascal_case.accepted b/birdie_snapshots/generated_type_has_the_same_name_as_the_function_but_in_pascal_case.accepted index 346d727..c0487d4 100644 --- a/birdie_snapshots/generated_type_has_the_same_name_as_the_function_but_in_pascal_case.accepted +++ b/birdie_snapshots/generated_type_has_the_same_name_as_the_function_but_in_pascal_case.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: generated type has the same name as the function but in pascal case file: ./test/squirrel_test.gleam test_name: generated_type_has_the_same_name_as_the_function_but_in_pascal_case_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/insert_with_no_returned_values_returns_just_nil_and_doesnt_define_a_type.accepted b/birdie_snapshots/insert_with_no_returned_values_returns_just_nil_and_doesnt_define_a_type.accepted index e9d0042..32b4aeb 100644 --- a/birdie_snapshots/insert_with_no_returned_values_returns_just_nil_and_doesnt_define_a_type.accepted +++ b/birdie_snapshots/insert_with_no_returned_values_returns_just_nil_and_doesnt_define_a_type.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: insert with no returned values returns just nil and doesnt define a type file: ./test/squirrel_test.gleam test_name: insert_with_no_returned_values_returns_just_nil_and_doesnt_define_a_type_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/int_decoding.accepted b/birdie_snapshots/int_decoding.accepted index 1a279eb..12e0e7c 100644 --- a/birdie_snapshots/int_decoding.accepted +++ b/birdie_snapshots/int_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: int decoding file: ./test/squirrel_test.gleam test_name: int_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/int_encoding.accepted b/birdie_snapshots/int_encoding.accepted index 1b45ca1..c2f7ff9 100644 --- a/birdie_snapshots/int_encoding.accepted +++ b/birdie_snapshots/int_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: int encoding file: ./test/squirrel_test.gleam test_name: int_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/json_decoding.accepted b/birdie_snapshots/json_decoding.accepted index e5c0ce6..733ebe7 100644 --- a/birdie_snapshots/json_decoding.accepted +++ b/birdie_snapshots/json_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: json decoding file: ./test/squirrel_test.gleam test_name: json_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/json_encoding.accepted b/birdie_snapshots/json_encoding.accepted index b3d738b..7a43518 100644 --- a/birdie_snapshots/json_encoding.accepted +++ b/birdie_snapshots/json_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: json encoding file: ./test/squirrel_test.gleam test_name: json_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/json import pog diff --git a/birdie_snapshots/jsonb_decoding.accepted b/birdie_snapshots/jsonb_decoding.accepted index ba5f516..c765589 100644 --- a/birdie_snapshots/jsonb_decoding.accepted +++ b/birdie_snapshots/jsonb_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: jsonb decoding file: ./test/squirrel_test.gleam test_name: jsonb_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/jsonb_encoding.accepted b/birdie_snapshots/jsonb_encoding.accepted index e799aa4..16f9520 100644 --- a/birdie_snapshots/jsonb_encoding.accepted +++ b/birdie_snapshots/jsonb_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: jsonb encoding file: ./test/squirrel_test.gleam test_name: jsonb_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/json import pog diff --git a/birdie_snapshots/left_join_columns_are_optional.accepted b/birdie_snapshots/left_join_columns_are_optional.accepted index 8fdaa35..d6c69ae 100644 --- a/birdie_snapshots/left_join_columns_are_optional.accepted +++ b/birdie_snapshots/left_join_columns_are_optional.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: left join columns are optional file: ./test/squirrel_test.gleam test_name: left_join_columns_are_optional_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/option.{type Option} import pog diff --git a/birdie_snapshots/left_join_nullability_inference.accepted b/birdie_snapshots/left_join_nullability_inference.accepted index 8f34057..75b1a49 100644 --- a/birdie_snapshots/left_join_nullability_inference.accepted +++ b/birdie_snapshots/left_join_nullability_inference.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: left join nullability inference file: ./test/squirrel_test.gleam test_name: left_join_nullability_inference_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/option.{type Option} import pog diff --git a/birdie_snapshots/nullability_with_foreign_key.accepted b/birdie_snapshots/nullability_with_foreign_key.accepted index e1f63cb..3acfcfd 100644 --- a/birdie_snapshots/nullability_with_foreign_key.accepted +++ b/birdie_snapshots/nullability_with_foreign_key.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: nullability with foreign key file: ./test/squirrel_test.gleam test_name: nullability_with_foreign_key_condition_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/option.{type Option} import pog diff --git a/birdie_snapshots/numeric_decoding.accepted b/birdie_snapshots/numeric_decoding.accepted index cf8d8d0..bd362f5 100644 --- a/birdie_snapshots/numeric_decoding.accepted +++ b/birdie_snapshots/numeric_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: numeric decoding file: ./test/squirrel_test.gleam test_name: numeric_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/numeric_encoding.accepted b/birdie_snapshots/numeric_encoding.accepted index 5cd6108..0f867d9 100644 --- a/birdie_snapshots/numeric_encoding.accepted +++ b/birdie_snapshots/numeric_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: numeric encoding file: ./test/squirrel_test.gleam test_name: numeric_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/optional_decoding.accepted b/birdie_snapshots/optional_decoding.accepted index 3cc6c06..c489204 100644 --- a/birdie_snapshots/optional_decoding.accepted +++ b/birdie_snapshots/optional_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: optional decoding file: ./test/squirrel_test.gleam test_name: optional_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/option.{type Option} import pog diff --git a/birdie_snapshots/queries_are_sorted_alphabetically.accepted b/birdie_snapshots/queries_are_sorted_alphabetically.accepted index 4e0a952..50dee75 100644 --- a/birdie_snapshots/queries_are_sorted_alphabetically.accepted +++ b/birdie_snapshots/queries_are_sorted_alphabetically.accepted @@ -4,6 +4,13 @@ title: queries are sorted alphabetically file: ./test/squirrel_test.gleam test_name: queries_are_sorted_alphabetically_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/query_starting_with_a_semicolon_does_not_crash.accepted b/birdie_snapshots/query_starting_with_a_semicolon_does_not_crash.accepted index d0b1914..12dadf6 100644 --- a/birdie_snapshots/query_starting_with_a_semicolon_does_not_crash.accepted +++ b/birdie_snapshots/query_starting_with_a_semicolon_does_not_crash.accepted @@ -4,6 +4,13 @@ title: query starting with a semicolon does not crash file: ./test/squirrel_test.gleam test_name: query_starting_with_a_semicolon_does_not_crash_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/query_that_needs_more_than_a_single_helper_function.accepted b/birdie_snapshots/query_that_needs_more_than_a_single_helper_function.accepted index 2e6484c..68f6b80 100644 --- a/birdie_snapshots/query_that_needs_more_than_a_single_helper_function.accepted +++ b/birdie_snapshots/query_that_needs_more_than_a_single_helper_function.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: query that needs more than a single helper function file: ./test/squirrel_test.gleam test_name: query_that_needs_more_than_a_single_helper_function_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/time/calendar.{type Date} import pog diff --git a/birdie_snapshots/query_that_needs_utils_and_enums_has_two_sections.accepted b/birdie_snapshots/query_that_needs_utils_and_enums_has_two_sections.accepted index 65c4ec4..c278daa 100644 --- a/birdie_snapshots/query_that_needs_utils_and_enums_has_two_sections.accepted +++ b/birdie_snapshots/query_that_needs_utils_and_enums_has_two_sections.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: query that needs utils and enums has two sections file: ./test/squirrel_test.gleam test_name: query_that_needs_utils_and_enums_has_two_sections_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/time/calendar.{type Date} import pog diff --git a/birdie_snapshots/query_with_comment.accepted b/birdie_snapshots/query_with_comment.accepted index 349537a..c70f195 100644 --- a/birdie_snapshots/query_with_comment.accepted +++ b/birdie_snapshots/query_with_comment.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: query with comment file: ./test/squirrel_test.gleam test_name: query_with_comment_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/query_with_multiline_comment.accepted b/birdie_snapshots/query_with_multiline_comment.accepted index 2b26dab..222ef4d 100644 --- a/birdie_snapshots/query_with_multiline_comment.accepted +++ b/birdie_snapshots/query_with_multiline_comment.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: query with multiline comment file: ./test/squirrel_test.gleam test_name: query_with_multiline_comment_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/query_with_quoted_string_is_properly_escaped.accepted b/birdie_snapshots/query_with_quoted_string_is_properly_escaped.accepted index 9eecb24..759194d 100644 --- a/birdie_snapshots/query_with_quoted_string_is_properly_escaped.accepted +++ b/birdie_snapshots/query_with_quoted_string_is_properly_escaped.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: query with quoted string is properly escaped file: ./test/squirrel_test.gleam test_name: query_with_quoted_string_is_properly_escaped_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/recursive_common_table_query_with_semi_join.accepted b/birdie_snapshots/recursive_common_table_query_with_semi_join.accepted index 6b062b5..a5b17a4 100644 --- a/birdie_snapshots/recursive_common_table_query_with_semi_join.accepted +++ b/birdie_snapshots/recursive_common_table_query_with_semi_join.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: recursive common table query with semi join file: ./test/squirrel_test.gleam test_name: recursive_common_table_query_with_semi_join_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog import youid/uuid.{type Uuid} diff --git a/birdie_snapshots/right_join_columns_are_optional.accepted b/birdie_snapshots/right_join_columns_are_optional.accepted index 762eb01..ecd0cde 100644 --- a/birdie_snapshots/right_join_columns_are_optional.accepted +++ b/birdie_snapshots/right_join_columns_are_optional.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: right join columns are optional file: ./test/squirrel_test.gleam test_name: right_join_columns_are_optional_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/option.{type Option} import pog diff --git a/birdie_snapshots/squirrel_supports_do_blocks.accepted b/birdie_snapshots/squirrel_supports_do_blocks.accepted index 144c33c..9453d5b 100644 --- a/birdie_snapshots/squirrel_supports_do_blocks.accepted +++ b/birdie_snapshots/squirrel_supports_do_blocks.accepted @@ -4,6 +4,13 @@ title: squirrel supports do blocks file: ./test/squirrel_test.gleam test_name: squirrel_supports_do_blocks_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/string_decoding.accepted b/birdie_snapshots/string_decoding.accepted index 0e7b7f8..95e89bb 100644 --- a/birdie_snapshots/string_decoding.accepted +++ b/birdie_snapshots/string_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: string decoding file: ./test/squirrel_test.gleam test_name: string_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/string_encoding.accepted b/birdie_snapshots/string_encoding.accepted index 487cfb3..ad5f579 100644 --- a/birdie_snapshots/string_encoding.accepted +++ b/birdie_snapshots/string_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: string encoding file: ./test/squirrel_test.gleam test_name: string_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/there_is_only_one_empty_line_between_code_generated_for_different_queries.accepted b/birdie_snapshots/there_is_only_one_empty_line_between_code_generated_for_different_queries.accepted index 3706bc0..872e719 100644 --- a/birdie_snapshots/there_is_only_one_empty_line_between_code_generated_for_different_queries.accepted +++ b/birdie_snapshots/there_is_only_one_empty_line_between_code_generated_for_different_queries.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: there is only one empty line between code generated for different queries file: ./test/squirrel_test.gleam test_name: there_is_only_one_empty_line_between_code_generated_for_different_queries_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/time_decoding.accepted b/birdie_snapshots/time_decoding.accepted index c96377e..53b7f9d 100644 --- a/birdie_snapshots/time_decoding.accepted +++ b/birdie_snapshots/time_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: time decoding file: ./test/squirrel_test.gleam test_name: time_of_day_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/time/calendar.{type TimeOfDay} import pog diff --git a/birdie_snapshots/time_encoding.accepted b/birdie_snapshots/time_encoding.accepted index 6e4ff80..9a9d0dc 100644 --- a/birdie_snapshots/time_encoding.accepted +++ b/birdie_snapshots/time_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: time encoding file: ./test/squirrel_test.gleam test_name: time_of_day_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/timestamp_decoding.accepted b/birdie_snapshots/timestamp_decoding.accepted index 4ba5bfb..ebc41f0 100644 --- a/birdie_snapshots/timestamp_decoding.accepted +++ b/birdie_snapshots/timestamp_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.1 +version: 1.3.2 title: timestamp decoding file: ./test/squirrel_test.gleam test_name: timestamp_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import gleam/time/timestamp.{type Timestamp} import pog diff --git a/birdie_snapshots/timestamp_encoding.accepted b/birdie_snapshots/timestamp_encoding.accepted index ac4a6cc..3b8545d 100644 --- a/birdie_snapshots/timestamp_encoding.accepted +++ b/birdie_snapshots/timestamp_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: timestamp encoding file: ./test/squirrel_test.gleam test_name: timestamp_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/using_uuids_more_than_once_results_in_a_single_uuid_decoder_helper.accepted b/birdie_snapshots/using_uuids_more_than_once_results_in_a_single_uuid_decoder_helper.accepted index f590e81..e6fc9f7 100644 --- a/birdie_snapshots/using_uuids_more_than_once_results_in_a_single_uuid_decoder_helper.accepted +++ b/birdie_snapshots/using_uuids_more_than_once_results_in_a_single_uuid_decoder_helper.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: using uuids more than once results in a single uuid decoder helper file: ./test/squirrel_test.gleam test_name: using_uuids_more_than_once_results_in_a_single_uuid_decoder_helper_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog import youid/uuid.{type Uuid} diff --git a/birdie_snapshots/uuid_decoding.accepted b/birdie_snapshots/uuid_decoding.accepted index d785683..8daf852 100644 --- a/birdie_snapshots/uuid_decoding.accepted +++ b/birdie_snapshots/uuid_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: uuid decoding file: ./test/squirrel_test.gleam test_name: uuid_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog import youid/uuid.{type Uuid} diff --git a/birdie_snapshots/uuid_encoding.accepted b/birdie_snapshots/uuid_encoding.accepted index a5ad064..3a0f665 100644 --- a/birdie_snapshots/uuid_encoding.accepted +++ b/birdie_snapshots/uuid_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: uuid encoding file: ./test/squirrel_test.gleam test_name: uuid_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog import youid/uuid diff --git a/birdie_snapshots/varchar_decoding.accepted b/birdie_snapshots/varchar_decoding.accepted index 012efeb..45f78a5 100644 --- a/birdie_snapshots/varchar_decoding.accepted +++ b/birdie_snapshots/varchar_decoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: varchar decoding file: ./test/squirrel_test.gleam test_name: varchar_decoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/birdie_snapshots/varchar_encoding.accepted b/birdie_snapshots/varchar_encoding.accepted index e3b50f9..6c3a6a0 100644 --- a/birdie_snapshots/varchar_encoding.accepted +++ b/birdie_snapshots/varchar_encoding.accepted @@ -1,9 +1,16 @@ --- -version: 1.3.0 +version: 1.3.2 title: varchar encoding file: ./test/squirrel_test.gleam test_name: varchar_encoding_test --- + +//// This module contains the code to run the sql queries defined in +//// `./test-directory`. +//// > 🐿️ This module was generated automatically using v-test of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +//// + import gleam/dynamic/decode import pog diff --git a/src/squirrel.gleam b/src/squirrel.gleam index 843c3f5..2471efe 100644 --- a/src/squirrel.gleam +++ b/src/squirrel.gleam @@ -345,7 +345,7 @@ fn write_queries( ) -> Dict(String, #(Int, List(Error))) { use directory, #(queries, errors) <- dict.map_values(queries) let output_file = directory_to_output_file(directory) - case write_queries_to_file(queries, to: output_file) { + case write_queries_to_file(queries, from: directory, to: output_file) { Ok(n) -> #(n, errors) Error(error) -> #(list.length(queries), [error, ..errors]) } @@ -353,13 +353,15 @@ fn write_queries( fn write_queries_to_file( queries: List(TypedQuery), + from queries_directory: String, to file: String, ) -> Result(Int, Error) { use <- bool.guard(when: queries == [], return: Ok(0)) let directory = filepath.directory_name(file) let _ = simplifile.create_directory_all(directory) - let code = query.generate_code(queries, squirrel_version) + let code = + query.generate_code(squirrel_version, for: queries, from: queries_directory) let try_write = simplifile.write(code, to: file) |> result.map_error(CannotWriteToFile(file, _)) @@ -417,7 +419,11 @@ fn check_queries_code( queries: List(TypedQuery), actual_code: String, ) -> CheckResult { - let expected_code = query.generate_code(queries, squirrel_version) + // The code is compared ignoring any comments, so we have no need to know + // what actual directory the queries come from: that information is only used + // to generate better comments! + let expected_code = + query.generate_code(squirrel_version, for: queries, from: "check-queries") compare_code_snippets(actual_code, expected_code) } diff --git a/src/squirrel/internal/query.gleam b/src/squirrel/internal/query.gleam index be7cd87..4f16a89 100644 --- a/src/squirrel/internal/query.gleam +++ b/src/squirrel/internal/query.gleam @@ -356,7 +356,12 @@ fn gleam_type_to_field_type( /// Generates the code for a single file containing a bunch of typed queries. /// -pub fn generate_code(queries: List(TypedQuery), version: String) -> String { +pub fn generate_code( + version version: String, + // The directory all the queries come from. + for queries: List(TypedQuery), + from directory: String, +) -> String { // We need to sort the queries before generating any code, otherwise the order // with which they will appear in the generated file won't be reproducible! // That could cause CI checks like `gleam run -m squirrel check` to fail. @@ -416,8 +421,12 @@ pub fn generate_code(queries: List(TypedQuery), version: String) -> String { } } - code - |> doc.append(doc.line) + doc.concat([ + doc.from_string(module_doc(version, directory)), + doc.lines(2), + code, + doc.line, + ]) |> doc.to_string(80) } @@ -524,6 +533,15 @@ fn pipe_all_encoders(doc: Document, decoders: List(Document)) -> Document { doc |> pipe_call_doc("pog.parameter", _, [decoder]) } +fn module_doc(version: String, directory: String) -> String { + " +//// This module contains the code to run the sql queries defined in +//// `" <> directory <> "`. +//// > 🐿️ This module was generated automatically using " <> version <> " of +//// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). +////" +} + fn function_doc(version: String, query: TypedQuery) -> String { let TypedQuery(comment:, name:, file:, ..) = query let function_name = gleam.value_identifier_to_string(name) diff --git a/test/squirrel_test.gleam b/test/squirrel_test.gleam index cc7f050..10c5cb4 100644 --- a/test/squirrel_test.gleam +++ b/test/squirrel_test.gleam @@ -204,7 +204,7 @@ fn should_codegen(query: String) -> String { fn should_codegen_queries(queries: List(#(String, String))) -> String { // We assert everything went smoothly and we have no errors in the query. let assert Ok(#(queries, [])) = type_queries(queries) - query.generate_code(queries, "v-test") + query.generate_code("v-test", for: queries, from: "./test-directory") } fn type_queries( From 6de4fbca5a9fedd2bc3a90d1cdfe7ec4e2f50ab6 Mon Sep 17 00:00:00 2001 From: Giacomo Cavalieri Date: Thu, 31 Jul 2025 14:10:07 +0200 Subject: [PATCH 2/3] update error message --- src/squirrel.gleam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/squirrel.gleam b/src/squirrel.gleam index 2471efe..d7f19cc 100644 --- a/src/squirrel.gleam +++ b/src/squirrel.gleam @@ -501,7 +501,7 @@ fn report_written_queries( doc.lines(2), flexible_string( "Hint: I look for all `*.sql` files in any directory called `sql` -under your project's `src` directory.", +under your project's `src`, `test`, and `dev` directories.", ), ] |> doc.concat From 3257fb540be0dffb9ab214c02a0c2801097c291e Mon Sep 17 00:00:00 2001 From: Giacomo Cavalieri Date: Thu, 31 Jul 2025 14:55:38 +0200 Subject: [PATCH 3/3] make sure to not overwrite any file --- CHANGELOG.md | 6 ++++ gleam.toml | 2 +- src/squirrel.gleam | 56 +++++++++++++++++++++++++++---- src/squirrel/internal/error.gleam | 18 ++++++++++ test/squirrel_test.gleam | 19 +++++++++++ 5 files changed, 93 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97a7c9a..0239b77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +- Before writing the generated queries, Squirrel will make sure to not overwrite + any file that was not automatically generated. + In case a file with the same name already exists, Squirrel will refuse to + overwrite it and prompt the used to first rename the existing file. + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) + - Squirrel will now include a doc comment at the beginning of each generated module, explaining where the queries come from and what version of squirrel was used to generate the code. diff --git a/gleam.toml b/gleam.toml index af741a2..7ad0d7a 100644 --- a/gleam.toml +++ b/gleam.toml @@ -3,7 +3,7 @@ version = "4.1.0" description = "🐿️ Type safe SQL in Gleam" licences = ["Apache-2.0"] repository = { type = "github", user = "giacomocavalieri", repo = "squirrel" } -gleam = ">= 1.7.0" +gleam = ">= 1.11.0" [dependencies] argv = ">= 1.0.2 and < 2.0.0" diff --git a/src/squirrel.gleam b/src/squirrel.gleam index d7f19cc..e57ed5c 100644 --- a/src/squirrel.gleam +++ b/src/squirrel.gleam @@ -17,8 +17,8 @@ import glexer/token import simplifile import squirrel/internal/database/postgres import squirrel/internal/error.{ - type Error, CannotReadFile, CannotWriteToFile, InvalidConnectionString, - OutdatedFile, + type Error, CannotOverwriteExistingFile, CannotReadFile, CannotWriteToFile, + InvalidConnectionString, OutdatedFile, } import squirrel/internal/project import squirrel/internal/query.{type TypedQuery} @@ -362,12 +362,54 @@ fn write_queries_to_file( let code = query.generate_code(squirrel_version, for: queries, from: queries_directory) - let try_write = - simplifile.write(code, to: file) - |> result.map_error(CannotWriteToFile(file, _)) - use _ <- result.try(try_write) - Ok(list.length(queries)) + safely_overwrite(to: file, content: code) + |> result.replace(list.length(queries)) +} + +fn safely_overwrite(to file: String, content code: String) -> Result(Nil, Error) { + case simplifile.read(file) |> result.map(classify_file_content) { + Ok(NotGenerated) | Error(simplifile.Enoent) -> + simplifile.write(code, to: file) + |> result.map_error(CannotWriteToFile(file, _)) + Ok(LikelyGenerated) -> Error(CannotOverwriteExistingFile(file)) + Error(reason) -> Error(CannotWriteToFile(file, reason)) + } +} + +@internal +pub fn classify_file_content(content: String) -> FileOrigin { + let likely_generated = + // In newer versions of squirrel this is always at the beginning of the + // file and it would be enough to check for this comment to establish if + // a file is generated or not... + string.contains( + content, + "> 🐿️ This module was generated automatically using", + ) + // ...but in older versions that module comment is not present! So we + // need to check if there's any function generated by squirrel. + || string.contains( + content, + "> 🐿️ This function was generated automatically using", + ) + + case likely_generated { + True -> LikelyGenerated + False -> NotGenerated + } +} + +@internal +pub type FileOrigin { + /// The file was most likely generated by Squirrel. It can safely be + /// overwritten as we do not risk deleting code written by a human. + /// + LikelyGenerated + + /// The file was most likely not generated by Squirrel. It is not safe to + /// overwrite it, or we'd risk deleting code written by a human! + NotGenerated } fn directory_to_output_file(directory: String) -> String { diff --git a/src/squirrel/internal/error.gleam b/src/squirrel/internal/error.gleam index 1b49f2d..1acb0c6 100644 --- a/src/squirrel/internal/error.gleam +++ b/src/squirrel/internal/error.gleam @@ -208,6 +208,16 @@ pub type Error { /// that would be generated by squirrel. /// OutdatedFile(file: String) + + /// This happens when the code generated by Squirrel would end up overriding + /// an existing file that was not generated by Squirrel. + /// We really want to avoid this, otherwise we'd end up deleting human written + /// code! + /// + /// For example if I have an already existing `my_app/sql.gleam` file, I don't + /// want Squirrel to silently replace its content with the generated code! + /// + CannotOverwriteExistingFile(file: String) } pub type ValueIdentifierError { @@ -623,6 +633,14 @@ This is most definitely a bug!", <> " is outdated, try running `gleam run -m squirrel` to generate a new up to date version.", ) + + CannotOverwriteExistingFile(file:) -> + printable_error("Cannot overwrite file") + |> add_paragraph( + "It looks like " <> style_file(file) <> " already exists and was not +generated by Squirrel, I cannot overwrite it!", + ) + |> hint("Rename the file and run `gleam run -m squirrel` again.") } printable_error_to_doc(printable_error) diff --git a/test/squirrel_test.gleam b/test/squirrel_test.gleam index 10c5cb4..200d8c1 100644 --- a/test/squirrel_test.gleam +++ b/test/squirrel_test.gleam @@ -880,3 +880,22 @@ pub fn squirrel_supports_do_blocks_test() { |> should_codegen |> birdie.snap(title: "squirrel supports do blocks") } + +pub fn file_with_squirrel_module_comment_is_considered_as_generated_test() { + assert squirrel.LikelyGenerated + == "select 1 as wibble" + |> should_codegen + |> squirrel.classify_file_content +} + +pub fn file_with_squirrel_function_comment_is_considered_as_generated_test() { + assert squirrel.LikelyGenerated + == "select 1 as wibble" + |> should_codegen + // We remove the starting module comment, since we want to make sure + // squirrel can pick up a generated file even if that bit is missing! + |> string.split(on: "\n") + |> list.filter(fn(line) { !string.starts_with(line, "////") }) + |> string.join(with: "\n") + |> squirrel.classify_file_content +}