From 22ff4abe7ed83dd775cad49f29edafa8cfbcac21 Mon Sep 17 00:00:00 2001 From: inoas Date: Mon, 7 Jul 2025 19:25:42 +0200 Subject: [PATCH 1/4] upgrade to support `pog ~> 4.0` --- .github/workflows/abstract_test.yml | 4 +- .github/workflows/test.yml | 8 ++-- .tool-versions | 6 +-- CHANGELOG.md | 4 ++ gleam.toml | 13 ++--- manifest.toml | 42 +++++++++-------- src/cake/adapter/postgres.gleam | 73 ++++++++++++++++++++++------- 7 files changed, 100 insertions(+), 50 deletions(-) diff --git a/.github/workflows/abstract_test.yml b/.github/workflows/abstract_test.yml index 5242449..566d365 100644 --- a/.github/workflows/abstract_test.yml +++ b/.github/workflows/abstract_test.yml @@ -6,10 +6,10 @@ on: gleam_version: type: string required: true - default: "1.9.0" + default: "1.10.0" erlang_version: type: string - default: "26" + default: "27" test_erlang: type: boolean default: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b220378..982f5e5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,14 +11,14 @@ jobs: test_lowest: uses: ./.github/workflows/abstract_test.yml with: - erlang_version: "26" - gleam_version: "1.9.0" + erlang_version: "27" + gleam_version: "1.10.0" test_erlang: true test_node: false test_highest: uses: ./.github/workflows/abstract_test.yml with: - erlang_version: "27" - gleam_version: "1.9.1" + erlang_version: "28" + gleam_version: "1.11.1" test_erlang: true test_node: false diff --git a/.tool-versions b/.tool-versions index feaece2..a9cfd5a 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,4 +1,4 @@ -# erlang 26.2.5.6 -erlang 27.3.1 -gleam 1.9.1 +# erlang 27.3.1 +erlang 28.0.1 +gleam 1.11.1 # gleam nightly diff --git a/CHANGELOG.md b/CHANGELOG.md index b5e99b3..a53cf4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +## [1.2.0] - 2025-07-07 + +- Utilize `pog ~> 4.0.0` dependency. + ## [1.1.1] - 2025-04-02 - Updated dependencies. diff --git a/gleam.toml b/gleam.toml index 4c14c27..c759d3d 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,11 +1,11 @@ name = "cake_pog" -version = "1.1.1" +version = "1.2.0" description = "🎂Cake 🐘PostgreSQL adapter which passes PreparedStatements to the pog library for execution written in Gleam." licences = ["MPL-2.0"] repository = { type = "github", user = "inoas", repo = "gleam-cake-pog" } # links = [{ title = "Website", href = "https://gleam.run" }] -gleam = ">= 1.9.0" +gleam = ">= 1.10.0" [documentation] pages = [ @@ -13,11 +13,12 @@ pages = [ ] [dependencies] -cake = ">= 2.1.0 and < 3.0.0" -gleam_stdlib = ">= 0.58.0 and < 2.0.0" -pog = ">= 3.2.0 and < 4.0.0" +cake = ">= 2.1.1 and < 3.0.0" +gleam_erlang = ">= 1.2.0 and < 2.0.0" +gleam_stdlib = ">= 0.61.0 and < 2.0.0" +pog = ">= 4.0.0 and < 5.0.0" [dev-dependencies] birdie = ">= 1.2.6 and < 2.0.0" gleeunit = ">= 1.3.0 and < 2.0.0" -pprint = ">= 1.0.4 and < 2.0.0" +pprint = ">= 1.0.6 and < 2.0.0" diff --git a/manifest.toml b/manifest.toml index eea79fd..a666629 100644 --- a/manifest.toml +++ b/manifest.toml @@ -4,36 +4,40 @@ packages = [ { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" }, { name = "backoff", version = "1.1.6", build_tools = ["rebar3"], requirements = [], otp_app = "backoff", source = "hex", outer_checksum = "CF0CFFF8995FB20562F822E5CC47D8CCF664C5ECDC26A684CBE85C225F9D7C39" }, - { name = "birdie", version = "1.2.6", build_tools = ["gleam"], requirements = ["argv", "edit_distance", "filepath", "glance", "gleam_community_ansi", "gleam_erlang", "gleam_stdlib", "justin", "rank", "simplifile", "term_size", "trie_again"], otp_app = "birdie", source = "hex", outer_checksum = "1363F4C7E7433A4A8350CC682BCDDBA5BBC6F66C94EFC63BC43025F796C4F6D0" }, - { name = "cake", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "cake", source = "hex", outer_checksum = "141FEBE63A3BBD2872232BBB61B83E75F9367A4C07DD825286D58AF8D86D7702" }, + { name = "birdie", version = "1.3.1", build_tools = ["gleam"], requirements = ["argv", "edit_distance", "filepath", "glance", "gleam_community_ansi", "gleam_stdlib", "justin", "rank", "simplifile", "term_size", "trie_again"], otp_app = "birdie", source = "hex", outer_checksum = "F811C9EDAF920EF48597A26E788907AAF80D9239A5E8C8CCFBD0DD1BB10184D7" }, + { name = "cake", version = "2.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "cake", source = "hex", outer_checksum = "D0EA8E576457F35C355CB40A934D4F20140C6DD5E24946150B36E909B5B33F54" }, { name = "edit_distance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "edit_distance", source = "hex", outer_checksum = "A1E485C69A70210223E46E63985FA1008B8B2DDA9848B7897469171B29020C05" }, + { name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" }, { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, { name = "glam", version = "2.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glam", source = "hex", outer_checksum = "4932A2D139AB0389E149396407F89654928D7B815E212BB02F13C66F53B1BBA1" }, - { name = "glance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "106111453AE9BA959184302B7DADF2E8CF322B27A7CB68EE78F3EE43FEACCE2C" }, + { name = "glance", version = "5.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "glexer"], otp_app = "glance", source = "hex", outer_checksum = "FAA3DAC74AF71D47C67D88EB32CE629075169F878D148BB1FF225439BE30070A" }, { name = "gleam_community_ansi", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8A62AE9CC6EA65BEA630D95016D6C07E4F9973565FA3D0DE68DC4200D8E0DD27" }, - { name = "gleam_community_colour", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "FDD6AC62C6EC8506C005949A4FCEF032038191D5EAAEC3C9A203CD53AE956ACA" }, - { name = "gleam_erlang", version = "0.34.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C38F2A128BAA0CEF17C3000BD2097EB80634E239CE31A86400C4416A5D0FDCC" }, - { name = "gleam_json", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C55C5C2B318533A8072D221C5E06E5A75711C129E420DD1CE463342106012E5D" }, - { name = "gleam_regexp", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "7F5E0C0BBEB3C58E57C9CB05FA9002F970C85AD4A63BA1E55CBCB35C15809179" }, - { name = "gleam_stdlib", version = "0.58.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "091F2D2C4A3A4E2047986C47E2C2C9D728A4E068ABB31FDA17B0D347E6248467" }, - { name = "gleeunit", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "0E6C83834BA65EDCAAF4FE4FB94AC697D9262D83E6F58A750D63C9F6C8A9D9FF" }, + { name = "gleam_community_colour", version = "2.0.2", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "E34DD2C896AC3792151EDA939DA435FF3B69922F33415ED3C4406C932FBE9634" }, + { name = "gleam_erlang", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "F91CE62A2D011FA13341F3723DB7DB118541AAA5FE7311BD2716D018F01EF9E3" }, + { name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" }, + { name = "gleam_otp", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "7020E652D18F9ABAC9C877270B14160519FA0856EE80126231C505D719AD68DA" }, + { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" }, + { name = "gleam_stdlib", version = "0.61.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "3DC407D6EDA98FCE089150C11F3AD892B6F4C3CA77C87A97BAE8D5AB5E41F331" }, + { name = "gleam_time", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "D71F1AFF7FEB534FF55E5DC58E534E9201BA75A444619788A2E4DEA4EBD87D16" }, + { name = "gleeunit", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "63022D81C12C17B7F1A60E029964E830A4CBD846BBC6740004FC1F1031AE0326" }, { name = "glexer", version = "2.2.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glexer", source = "hex", outer_checksum = "5C235CBDF4DA5203AD5EAB1D6D8B456ED8162C5424FE2309CFFB7EF438B7C269" }, { name = "justin", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "justin", source = "hex", outer_checksum = "7FA0C6DB78640C6DC5FBFD59BF3456009F3F8B485BF6825E97E1EB44E9A1E2CD" }, { name = "opentelemetry_api", version = "1.4.0", build_tools = ["rebar3", "mix"], requirements = [], otp_app = "opentelemetry_api", source = "hex", outer_checksum = "3DFBBFAA2C2ED3121C5C483162836C4F9027DEF469C41578AF5EF32589FCFC58" }, - { name = "pg_types", version = "0.4.0", build_tools = ["rebar3"], requirements = [], otp_app = "pg_types", source = "hex", outer_checksum = "B02EFA785CAECECF9702C681C80A9CA12A39F9161A846CE17B01FB20AEEED7EB" }, - { name = "pgo", version = "0.14.0", build_tools = ["rebar3"], requirements = ["backoff", "opentelemetry_api", "pg_types"], otp_app = "pgo", source = "hex", outer_checksum = "71016C22599936E042DC0012EE4589D24C71427D266292F775EBF201D97DF9C9" }, - { name = "pog", version = "3.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "pgo"], otp_app = "pog", source = "hex", outer_checksum = "63152DADEBAE3150C81E9612909974C3C38F3E35B41F252798069A2FD117308E" }, - { name = "pprint", version = "1.0.4", build_tools = ["gleam"], requirements = ["glam", "gleam_stdlib"], otp_app = "pprint", source = "hex", outer_checksum = "C310A98BDC0995644847C3C8702DE19656D6BCD638B2A8A358B97824379ECAA1" }, + { name = "pg_types", version = "0.5.0", build_tools = ["rebar3"], requirements = [], otp_app = "pg_types", source = "hex", outer_checksum = "A3023B464AA960BC1628635081E30CCA4F676F2D4C23CCD6179C1C11C9B4A642" }, + { name = "pgo", version = "0.15.0", build_tools = ["rebar3"], requirements = ["backoff", "opentelemetry_api", "pg_types"], otp_app = "pgo", source = "hex", outer_checksum = "4B883D751B8D4247F4D8A6FBAE58EDB6FA9DBC183371299BF84975EE36406388" }, + { name = "pog", version = "4.0.0", build_tools = ["gleam"], requirements = ["exception", "gleam_erlang", "gleam_otp", "gleam_stdlib", "gleam_time", "pgo"], otp_app = "pog", source = "hex", outer_checksum = "E495AAD2C4FD0BB3A92C505682705FA2460053B2D3ABC6F9024C3FED6868417D" }, + { name = "pprint", version = "1.0.6", build_tools = ["gleam"], requirements = ["glam", "gleam_stdlib"], otp_app = "pprint", source = "hex", outer_checksum = "4E9B34AE03B2E81D60F230B9BAF1792BE1AC37AFB5564B8DEBEE56BAEC866B7D" }, { name = "rank", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "rank", source = "hex", outer_checksum = "5660E361F0E49CBB714CC57CC4C89C63415D8986F05B2DA0C719D5642FAD91C9" }, - { name = "simplifile", version = "2.2.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "C88E0EE2D509F6D86EB55161D631657675AA7684DAB83822F7E59EB93D9A60E3" }, + { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" }, { name = "term_size", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "term_size", source = "hex", outer_checksum = "D00BD2BC8FB3EBB7E6AE076F3F1FF2AC9D5ED1805F004D0896C784D06C6645F1" }, - { name = "trie_again", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "trie_again", source = "hex", outer_checksum = "5B19176F52B1BD98831B57FDC97BD1F88C8A403D6D8C63471407E78598E27184" }, + { name = "trie_again", version = "1.1.3", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "trie_again", source = "hex", outer_checksum = "365FE609649F3A098D1D7FC7EA5222EE422F0B3745587BF2AB03352357CA70BB" }, ] [requirements] birdie = { version = ">= 1.2.6 and < 2.0.0" } -cake = { version = ">= 2.1.0 and < 3.0.0" } -gleam_stdlib = { version = ">= 0.58.0 and < 2.0.0" } +cake = { version = ">= 2.1.1 and < 3.0.0" } +gleam_erlang = { version = ">= 1.2.0 and < 2.0.0" } +gleam_stdlib = { version = ">= 0.61.0 and < 2.0.0" } gleeunit = { version = ">= 1.3.0 and < 2.0.0" } -pog = { version = ">= 3.2.0 and < 4.0.0" } -pprint = { version = ">= 1.0.4 and < 2.0.0" } +pog = { version = ">= 4.0.0 and < 5.0.0" } +pprint = { version = ">= 1.0.6 and < 2.0.0" } diff --git a/src/cake/adapter/postgres.gleam b/src/cake/adapter/postgres.gleam index 4b97657..e7a6b5a 100644 --- a/src/cake/adapter/postgres.gleam +++ b/src/cake/adapter/postgres.gleam @@ -11,11 +11,20 @@ import cake/param.{ type Param, BoolParam, FloatParam, IntParam, NullParam, StringParam, } import gleam/dynamic/decode.{type Decoder} +import gleam/erlang/process import gleam/list import gleam/option.{type Option} import pog.{type Connection, type QueryError, type Returned, type Value} -/// Connection to a PostgreSQL database. +const default_process_name = "cake_pog" + +/// Runs a callbakc on a connection to a PostgreSQL database. +/// +/// NOTICE: ⚠️⚠️⚠️ You should probably be using `gleam_erlang`'s +/// `supervisor.new`, `supervisor.add`, and `supervisor.start` instead, +/// to create the database connection. +/// +/// See `pog`'s official documentation . /// /// This is a thin wrapper around the `pog` library's `Connection` type. /// @@ -27,21 +36,53 @@ pub fn with_connection( database database: String, callback callback: fn(Connection) -> a, ) -> a { - let connection = - pog.Config( - ..pog.default_config(), - host: host, - port: port, - user: username, - password: password, - database: database, - ) - |> pog.connect - - let value = callback(connection) - pog.disconnect(connection) - - value + let process = process.new_name(default_process_name) + + with_named_connection( + process:, + host:, + port:, + username:, + password:, + database:, + callback:, + ) +} + +/// Runs a callback on a connection to a PostgreSQL database. +/// +/// NOTICE: ⚠️⚠️⚠️ You should probably be using `gleam_erlang`'s +/// `supervisor.new`, `supervisor.add`, and `supervisor.start` instead, +/// to create the database connection. +/// +/// See `pog`'s official documentation . +/// +/// This is a thin wrapper around the `pog` library's `Connection` type. +/// +/// In addition to `with_connection` you may specify the erlang process name. +/// +pub fn with_named_connection( + process process: process.Name(pog.Message), + host host: String, + port port: Int, + username username: String, + password password: Option(String), + database database: String, + callback callback: fn(Connection) -> a, +) -> a { + let pog_config = + pog.default_config(process) + |> pog.port(port) + |> pog.user(username) + |> pog.password(password) + |> pog.host(host) + |> pog.database(database) + + let assert Ok(actor) = pog.start(pog_config) + + let db = actor.data + + callback(db) } /// Convert a Cake `ReadQuery` to a `PreparedStatement`. From 370efa630ce2380d152f2132aee7e9a4aeefea3c Mon Sep 17 00:00:00 2001 From: inoas Date: Wed, 9 Jul 2025 22:03:52 +0200 Subject: [PATCH 2/4] fixes --- .../sh/create-database-gleam_cake_pog_test-postgres.sh | 10 ++++++++++ .github/sh/create-database-gleam_cake_test-postgres.sh | 10 ---------- .github/workflows/abstract_test.yml | 2 +- .tool-versions | 2 -- CHANGELOG.md | 2 +- docker-compose.yml | 6 ++++-- gleam.toml | 6 +++--- manifest.toml | 8 ++++---- src/cake/adapter/postgres.gleam | 8 ++++++-- test/test_helper/postgres_test_helper.gleam | 2 +- 10 files changed, 30 insertions(+), 26 deletions(-) create mode 100755 .github/sh/create-database-gleam_cake_pog_test-postgres.sh delete mode 100755 .github/sh/create-database-gleam_cake_test-postgres.sh diff --git a/.github/sh/create-database-gleam_cake_pog_test-postgres.sh b/.github/sh/create-database-gleam_cake_pog_test-postgres.sh new file mode 100755 index 0000000..8b91ff1 --- /dev/null +++ b/.github/sh/create-database-gleam_cake_pog_test-postgres.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +set -eu + +psql < -## [1.2.0] - 2025-07-07 +## [1.2.0] - 2025-07-09 - Utilize `pog ~> 4.0.0` dependency. diff --git a/docker-compose.yml b/docker-compose.yml index 799c2c8..eb75de3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,17 +12,19 @@ services: environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - - POSTGRES_DB=gleam_cake_test + - POSTGRES_DB=gleam_cake_pog_test + command: postgres -c 'max_connections=10' ports: - "127.0.0.1:5432:5432" volumes: - ./docker/data/postgres-data:/var/lib/postgresql/data # - ./sql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql healthcheck: - test: ["CMD-SHELL", "pg_isready", "-d", "gleam_cake_test"] + test: ["CMD-SHELL", "pg_isready", "-d", "db_prod"] interval: 30s timeout: 60s retries: 5 start_period: 80s + volumes: gleam-cake-pog-test: diff --git a/gleam.toml b/gleam.toml index c759d3d..d196808 100644 --- a/gleam.toml +++ b/gleam.toml @@ -13,12 +13,12 @@ pages = [ ] [dependencies] -cake = ">= 2.1.1 and < 3.0.0" +cake = ">= 2.1.2 and < 3.0.0" gleam_erlang = ">= 1.2.0 and < 2.0.0" gleam_stdlib = ">= 0.61.0 and < 2.0.0" pog = ">= 4.0.0 and < 5.0.0" [dev-dependencies] -birdie = ">= 1.2.6 and < 2.0.0" -gleeunit = ">= 1.3.0 and < 2.0.0" +birdie = ">= 1.3.1 and < 2.0.0" +gleeunit = ">= 1.6.0 and < 2.0.0" pprint = ">= 1.0.6 and < 2.0.0" diff --git a/manifest.toml b/manifest.toml index a666629..55f743c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ packages = [ { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" }, { name = "backoff", version = "1.1.6", build_tools = ["rebar3"], requirements = [], otp_app = "backoff", source = "hex", outer_checksum = "CF0CFFF8995FB20562F822E5CC47D8CCF664C5ECDC26A684CBE85C225F9D7C39" }, { name = "birdie", version = "1.3.1", build_tools = ["gleam"], requirements = ["argv", "edit_distance", "filepath", "glance", "gleam_community_ansi", "gleam_stdlib", "justin", "rank", "simplifile", "term_size", "trie_again"], otp_app = "birdie", source = "hex", outer_checksum = "F811C9EDAF920EF48597A26E788907AAF80D9239A5E8C8CCFBD0DD1BB10184D7" }, - { name = "cake", version = "2.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "cake", source = "hex", outer_checksum = "D0EA8E576457F35C355CB40A934D4F20140C6DD5E24946150B36E909B5B33F54" }, + { name = "cake", version = "2.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "cake", source = "hex", outer_checksum = "E692DED831B81F34CEB52042E27A9D1F78684BDF58E26B9245550D5613B4F2CE" }, { name = "edit_distance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "edit_distance", source = "hex", outer_checksum = "A1E485C69A70210223E46E63985FA1008B8B2DDA9848B7897469171B29020C05" }, { name = "exception", version = "2.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "329D269D5C2A314F7364BD2711372B6F2C58FA6F39981572E5CA68624D291F8C" }, { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, @@ -34,10 +34,10 @@ packages = [ ] [requirements] -birdie = { version = ">= 1.2.6 and < 2.0.0" } -cake = { version = ">= 2.1.1 and < 3.0.0" } +birdie = { version = ">= 1.3.1 and < 2.0.0" } +cake = { version = ">= 2.1.2 and < 3.0.0" } gleam_erlang = { version = ">= 1.2.0 and < 2.0.0" } gleam_stdlib = { version = ">= 0.61.0 and < 2.0.0" } -gleeunit = { version = ">= 1.3.0 and < 2.0.0" } +gleeunit = { version = ">= 1.6.0 and < 2.0.0" } pog = { version = ">= 4.0.0 and < 5.0.0" } pprint = { version = ">= 1.0.6 and < 2.0.0" } diff --git a/src/cake/adapter/postgres.gleam b/src/cake/adapter/postgres.gleam index e7a6b5a..df9d031 100644 --- a/src/cake/adapter/postgres.gleam +++ b/src/cake/adapter/postgres.gleam @@ -79,10 +79,14 @@ pub fn with_named_connection( |> pog.database(database) let assert Ok(actor) = pog.start(pog_config) - + let pid = actor.pid let db = actor.data - callback(db) + let value = callback(db) + + process.send_exit(pid) + + value } /// Convert a Cake `ReadQuery` to a `PreparedStatement`. diff --git a/test/test_helper/postgres_test_helper.gleam b/test/test_helper/postgres_test_helper.gleam index 6f0622e..92cfbd3 100644 --- a/test/test_helper/postgres_test_helper.gleam +++ b/test/test_helper/postgres_test_helper.gleam @@ -9,7 +9,7 @@ fn with_local_test_connection(callback callback) { port: 5432, username: "postgres", password: Some("postgres"), - database: "gleam_cake_test", + database: "gleam_cake_pog_test", callback:, ) } From 16d321c94567826f7a9084c897963fab00eca356 Mon Sep 17 00:00:00 2001 From: inoas Date: Wed, 9 Jul 2025 22:12:07 +0200 Subject: [PATCH 3/4] fix --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index eb75de3..106ec83 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: - ./docker/data/postgres-data:/var/lib/postgresql/data # - ./sql/create_tables.sql:/docker-entrypoint-initdb.d/create_tables.sql healthcheck: - test: ["CMD-SHELL", "pg_isready", "-d", "db_prod"] + test: ["CMD-SHELL", "pg_isready", "-d", "gleam_cake_pog_test"] interval: 30s timeout: 60s retries: 5 From 739f43a4e5b9b042ee4b25b4ebbbb6c97c301c86 Mon Sep 17 00:00:00 2001 From: inoas Date: Wed, 9 Jul 2025 22:13:42 +0200 Subject: [PATCH 4/4] fix --- .github/workflows/abstract_test.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/abstract_test.yml b/.github/workflows/abstract_test.yml index 2568f60..a38f74f 100644 --- a/.github/workflows/abstract_test.yml +++ b/.github/workflows/abstract_test.yml @@ -6,7 +6,7 @@ on: gleam_version: type: string required: true - default: "1.10.0" + default: "1.11.1" erlang_version: type: string default: "27" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 982f5e5..8d32cbd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: uses: ./.github/workflows/abstract_test.yml with: erlang_version: "27" - gleam_version: "1.10.0" + gleam_version: "1.11.1" test_erlang: true test_node: false test_highest: