Skip to content

Commit

Permalink
🎉 Hello, Joe!
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri committed Aug 8, 2024
0 parents commit 03c98f0
Show file tree
Hide file tree
Showing 23 changed files with 4,275 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test

on:
push:
branches:
- master
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: "26.0.2"
gleam-version: "1.4.0-rc1"
rebar3-version: "3"
# elixir-version: "1.15.4"
- run: gleam deps download
- run: gleam test
- run: gleam format --check src test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.beam
*.ez
/build
erl_crash.dump
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# squirrel

[![Package Version](https://img.shields.io/hexpm/v/squirrel)](https://hex.pm/packages/squirrel)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/squirrel/)

```gleam
import squirrel
pub fn main() {
// TODO: An example of the project in use
}
```

Further documentation can be found at <https://hexdocs.pm/squirrel>.

## Development

```sh
gleam run # Run the project
gleam test # Run the tests
```
33 changes: 33 additions & 0 deletions birdie_snapshots/bool_decoding.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 1.1.8
title: bool decoding
file: ./test/squirrel_test.gleam
test_name: bool_decoding_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(res: Bool)
}

/// Runs the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db) {
let decoder =
decode.into({
use res <- decode.parameter
QueryRow(res: res)
})
|> decode.field(0, decode.bool)

"select true as res"
|> pgo.execute(db, [], decode.from(decoder, _))
}
33 changes: 33 additions & 0 deletions birdie_snapshots/bool_encoding.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 1.1.8
title: bool encoding
file: ./test/squirrel_test.gleam
test_name: bool_encoding_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(res: Bool)
}

/// Runs the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db, arg_1) {
let decoder =
decode.into({
use res <- decode.parameter
QueryRow(res: res)
})
|> decode.field(0, decode.bool)

"select true as res where $1 = true"
|> pgo.execute(db, [pgo.bool(arg_1)], decode.from(decoder, _))
}
33 changes: 33 additions & 0 deletions birdie_snapshots/int_decoding.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 1.1.8
title: int decoding
file: ./test/squirrel_test.gleam
test_name: int_decoding_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(res: Int)
}

/// Runs the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db) {
let decoder =
decode.into({
use res <- decode.parameter
QueryRow(res: res)
})
|> decode.field(0, decode.int)

"select 11 as res"
|> pgo.execute(db, [], decode.from(decoder, _))
}
33 changes: 33 additions & 0 deletions birdie_snapshots/int_encoding.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 1.1.8
title: int encoding
file: ./test/squirrel_test.gleam
test_name: int_encoding_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(res: Bool)
}

/// Runs the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db, arg_1) {
let decoder =
decode.into({
use res <- decode.parameter
QueryRow(res: res)
})
|> decode.field(0, decode.bool)

"select true as res where $1 = 11"
|> pgo.execute(db, [pgo.int(arg_1)], decode.from(decoder, _))
}
37 changes: 37 additions & 0 deletions birdie_snapshots/query_with_comment.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
version: 1.1.8
title: query with comment
file: ./test/squirrel_test.gleam
test_name: query_with_comment_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(name: String, acorns: Option(Int))
}

/// This is a comment
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db) {
let decoder =
decode.into({
use name <- decode.parameter
use acorns <- decode.parameter
QueryRow(name: name, acorns: acorns)
})
|> decode.field(0, decode.string)
|> decode.field(1, decode.optional(decode.int))

"
-- This is a comment
select * from squirrel
"
|> pgo.execute(db, [], decode.from(decoder, _))
}
39 changes: 39 additions & 0 deletions birdie_snapshots/query_with_multiline_comment.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
version: 1.1.8
title: query with multiline comment
file: ./test/squirrel_test.gleam
test_name: query_with_multiline_comment_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(name: String, acorns: Option(Int))
}

/// This is a comment
/// that goes over multiple lines!
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db) {
let decoder =
decode.into({
use name <- decode.parameter
use acorns <- decode.parameter
QueryRow(name: name, acorns: acorns)
})
|> decode.field(0, decode.string)
|> decode.field(1, decode.optional(decode.int))

"
-- This is a comment
-- that goes over multiple lines!
select * from squirrel
"
|> pgo.execute(db, [], decode.from(decoder, _))
}
33 changes: 33 additions & 0 deletions birdie_snapshots/string_decoding.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 1.1.8
title: string decoding
file: ./test/squirrel_test.gleam
test_name: string_decoding_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(res: String)
}

/// Runs the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db) {
let decoder =
decode.into({
use res <- decode.parameter
QueryRow(res: res)
})
|> decode.field(0, decode.string)

"select 'wibble' as res"
|> pgo.execute(db, [], decode.from(decoder, _))
}
33 changes: 33 additions & 0 deletions birdie_snapshots/string_encoding.accepted
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 1.1.8
title: string encoding
file: ./test/squirrel_test.gleam
test_name: string_encoding_test
---
/// A row you get from running the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This type definition was generated automatically using v-test of the
/// > [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub type QueryRow {
QueryRow(res: Bool)
}

/// Runs the `query` query
/// defined in `file.sql`.
///
/// > 🐿️ This function was generated automatically using v-test of
/// > the [squirrel package](https://github.com/giacomocavalieri/squirrel).
///
pub fn query(db, arg_1) {
let decoder =
decode.into({
use res <- decode.parameter
QueryRow(res: res)
})
|> decode.field(0, decode.bool)

"select true as res where $1 = 'wibble'"
|> pgo.execute(db, [pgo.text(arg_1)], decode.from(decoder, _))
}
25 changes: 25 additions & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name = "squirrel"
version = "0.1.0"
description = "🐿️ Type safe SQL in Gleam"
licences = ["Apache-2.0"]
repository = { type = "github", user = "giacomocavalieri", repo = "squirrel" }

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
simplifile = ">= 2.0.1 and < 3.0.0"
eval = ">= 1.0.0 and < 2.0.0"
gleam_json = ">= 1.0.0 and < 2.0.0"
mug = ">= 1.1.0 and < 2.0.0"
glam = ">= 2.0.1 and < 3.0.0"
justin = ">= 1.0.1 and < 2.0.0"
filepath = ">= 1.0.0 and < 2.0.0"
gleam_community_ansi = ">= 1.4.0 and < 2.0.0"
term_size = ">= 1.0.1 and < 2.0.0"
argv = ">= 1.0.2 and < 2.0.0"
envoy = ">= 1.0.1 and < 2.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"
birdie = ">= 1.1.8 and < 2.0.0"
temporary = ">= 1.0.0 and < 2.0.0"
gleam_pgo = ">= 0.13.0 and < 1.0.0"
Loading

0 comments on commit 03c98f0

Please sign in to comment.