jade-sql 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82ae87a5571e7ef32804036dd347134fc11bcf20a66ebabe7562ac898f943262
4
- data.tar.gz: c81268fa4accc4f8bb8f945a8ba164a64ac0ca629d554c9d99874ecb4fb697d5
3
+ metadata.gz: 75f58977c75363b33bfd885e9059624c732f81b14ed764e8fc8f6ffc70842209
4
+ data.tar.gz: 94ab9ce7fcc86ce8ac9e6868ffa8b0a7284af351baa1c1785db74921de419c56
5
5
  SHA512:
6
- metadata.gz: c1cbadd648ec547bcd888c79504d40b630b7e808f0ef0b1e0f379d8b581816d1c3110112fbed3b597dae9987270b13082e68b0561a6ea5bfec2637e7fc81bc4d
7
- data.tar.gz: 2864083ceebdd23042ddcd31a3c81d2446b1533b5a7ba8614565138899de6d8fea76bb6a485a8781d16315174cf1856f989890664157bb371ab56cfae2a4e63f
6
+ metadata.gz: 3ea0a83ac2633a0096e848e0cf774f003772d6f1f166f72a525ba831d47b6ad2ef36b13d993004e551db9a18a3b43c99b004a04daf86fefe0bcaca689ab72014
7
+ data.tar.gz: 3cf14a376b2195bca477c521820982e785b5669cab11ec3401e2f11ca03cbeeb6da5abe3489c58db198acf181d5dc0bf6c0014454b21f804923e18cfc74f2eb6
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![CI](https://github.com/agustinrhcp/jade-sql/actions/workflows/ci.yml/badge.svg)](https://github.com/agustinrhcp/jade-sql/actions/workflows/ci.yml)
4
4
 
5
- Type-safe SQL for Jade. Builds queries and mutations from a generated
5
+ Type-safe SQL for Jade. Builds queries and writes from a generated
6
6
  schema, renders them to `(String, List(Value))`, and runs them against
7
7
  ActiveRecord via a Task port that auto-decodes rows into typed Jade
8
8
  structs.
@@ -24,22 +24,28 @@ To execute queries at runtime, opt into the AR-backed task port:
24
24
  require 'jade-sql/runtime'
25
25
  ```
26
26
 
27
- To get the rake task for schema generation:
27
+ To get the rake tasks for schema generation:
28
28
 
29
29
  ```ruby
30
30
  # Rakefile (or lib/tasks/jade.rake)
31
31
  load Gem.find_files('jade-sql/tasks.rake').first
32
32
  ```
33
33
 
34
+ `rake jade:schema` writes the schema; `rake jade:schema:check` fails when the
35
+ checked-in one no longer matches `db/structure.sql`, which is what a migration
36
+ merged without regenerating looks like. Both are also `jade-sql schema` and
37
+ `jade-sql schema --check`.
38
+
34
39
  ## At a glance
35
40
 
36
41
  Generate a typed schema from `db/structure.sql`, then build a query against
37
- it. The result is a `Q` you render with `to_sql` or run with `fetch_*`; rows
42
+ it. The result is a `Query` you render with `to_sql` or run with `fetch_*`; rows
38
43
  decode straight into your struct.
39
44
 
40
45
  ```jade
41
- import Sql exposing (Selector, eq, to_expr)
42
- import Sql.Query exposing (Q, field, from, join, select, where)
46
+ import Sql exposing (Selector, eq)
47
+ import Sql.Expr as Expr
48
+ import Sql.Query exposing (Query, field, from, join, select, where)
43
49
  import Schema exposing (patients, appointments)
44
50
 
45
51
  struct Visit = {
@@ -47,14 +53,14 @@ struct Visit = {
47
53
  reason: String
48
54
  }
49
55
 
50
- def scheduled_visits -> Q(Selector(Visit))
56
+ def scheduled_visits -> Select(Visit)
51
57
  p <- from(patients)
52
- a <- join(appointments, (a) -> { p.id |> eq(a.patient_id) })
58
+ a <- join(appointments, (a) -> { p.id |> Expr.eq(a.patient_id) })
53
59
 
54
60
  select(Visit(_, _))
55
61
  |> field(p.name)
56
62
  |> field(a.reason)
57
- |> where(a.status |> eq(to_expr("scheduled")))
63
+ |> where(a.status |> eq("scheduled"))
58
64
  end
59
65
  ```
60
66
 
@@ -65,6 +71,6 @@ that decodes each row into `Visit`.
65
71
 
66
72
  - [Building SQL](docs/building.md) — generate a schema, build queries
67
73
  (joins, sorting/grouping, pagination, aggregates, arrays, JSONB) and
68
- mutations (insert/update/delete, RETURNING, timestamps, UUIDs).
69
- - [Running queries and mutations](docs/running.md) — `fetch_*` / `execute`,
74
+ writes (insert/update/delete, RETURNING, timestamps, UUIDs).
75
+ - [Running queries and writes](docs/running.md) — `fetch_*` / `execute`,
70
76
  transactions, and testing without a database.