🐿️ Type safe SQL in Gleam
81

Configure Feed

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

add test to check strings are properly escaped

Giacomo Cavalieri (May 18, 2025, 3:56 PM +0200) ddbc7fc8 9978404e

+42
+36
birdie_snapshots/query_with_quoted_string_is_properly_escaped.accepted
··· 1 + --- 2 + version: 1.3.0 3 + title: query with quoted string is properly escaped 4 + file: ./test/squirrel_test.gleam 5 + test_name: query_with_quoted_string_is_properly_escaped_test 6 + --- 7 + import gleam/dynamic/decode 8 + import pog 9 + 10 + /// A row you get from running the `query` query 11 + /// defined in `query.sql`. 12 + /// 13 + /// > 🐿️ This type definition was generated automatically using v-test of the 14 + /// > [squirrel package](https://github.com/giacomocavalieri/squirrel). 15 + /// 16 + pub type QueryRow { 17 + QueryRow(result: Int) 18 + } 19 + 20 + /// Runs the `query` query 21 + /// defined in `query.sql`. 22 + /// 23 + /// > 🐿️ This function was generated automatically using v-test of 24 + /// > the [squirrel package](https://github.com/giacomocavalieri/squirrel). 25 + /// 26 + pub fn query(db) { 27 + let decoder = { 28 + use result <- decode.field(0, decode.int) 29 + decode.success(QueryRow(result:)) 30 + } 31 + 32 + "select 1 as \"result\"" 33 + |> pog.query 34 + |> pog.returning(decoder) 35 + |> pog.execute(db) 36 + }
+6
test/squirrel_test.gleam
··· 551 551 |> birdie.snap(title: "query that needs utils and enums has two sections") 552 552 } 553 553 554 + pub fn query_with_quoted_string_is_properly_escaped_test() { 555 + "select 1 as \"result\"" 556 + |> should_codegen 557 + |> birdie.snap(title: "query with quoted string is properly escaped") 558 + } 559 + 554 560 // --- ERRROR TESTS ------------------------------------------------------------ 555 561 // This is a group of tests to ensure that the errors look good when something 556 562 // goes wrong.