diff --git a/CHANGELOG.md b/CHANGELOG.md index 2486261..0342021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,14 @@ becomes the release notes of the next tag. ## [Unreleased] +### Documentation + +- Fix the quickstart (the `Location` and `unknown_column` samples, the + PostGIS image version, a `git clone` step, the `anonymous` role the fixture + already creates), the `--print-sql` "without a database" claim, and refresh + the migrating-from-postgrest guide (preference prerequisites, `PUT` + semantics, role inheritance on PostgreSQL 16 and later). + ## [1.0.0-rc.1] - 2026-11-24 ### Fixed diff --git a/README.md b/README.md index bd1ced2..e373eef 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,8 @@ $ curl 'localhost:8080/users?select=id,email,posts(title)&mood=eq.happy&limit=2' [docs/contracts.md](docs/contracts.md). - **Pipe-friendly CLI** — `pdbr request GET '/users?select=id' | jq` prints the body, exits non-zero on 4xx/5xx, and `--print-sql` shows the exact - statement without a database. + statement without executing it (with `--schema.cache_path`, without a + database). - **Library embedding (experimental)** — `pdbr.New(cfg, pdbr.WithPlugins(...)).Handler(ctx)` mounts the whole API (watch mode included) in your own `net/http` mux. The Go API is outside the 1.0 compatibility promise. @@ -94,6 +95,7 @@ $ go install github.com/suprbdev/pdbr/cmd/pdbr@latest ## Quickstart ```console +$ git clone https://github.com/suprbdev/pdbr && cd pdbr $ make dev # PostGIS-enabled Postgres + fixture + pdbr in watch mode (no host ports: add compose.override.yaml) $ curl localhost:8080/openapi.json | jq .paths | head ``` diff --git a/docs/deployment.md b/docs/deployment.md index fcf37e4..593fd95 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -45,7 +45,7 @@ reach PostgreSQL without restarting it. ## Local stack (compose) -`compose.yaml` runs `postgis/postgis:16-3.4` initialised with the fixture +`compose.yaml` runs `postgis/postgis:18-3.7` initialised with the fixture schema (`db/init/01-schema.sql`, regenerated from pdbcore with `make fixture`) plus pdbr in watch mode without authentication, as the connection role (`auth.mode: none`, `roles.switch: false`), and `errors.detail: dev`. It publishes diff --git a/docs/features.md b/docs/features.md index 9113a50..6b3394d 100644 --- a/docs/features.md +++ b/docs/features.md @@ -335,7 +335,7 @@ These shipped features are outside the 1.0 compatibility promise: they may chang ## Ops & delivery - [x] Multi-stage Dockerfile (`golang:1.26-alpine` → distroless nonroot, `ENTRYPOINT ["/pdbr"] CMD ["serve"]`) (parity) -- [x] Compose dev stack (`postgis/postgis:16-3.4` + fixture + watch mode, no host ports, gitignored `compose.override.yaml`) and `compose.test.yaml` (parity) +- [x] Compose dev stack (`postgis/postgis:18-3.7` + fixture + watch mode, no host ports, gitignored `compose.override.yaml`) and `compose.test.yaml` (parity) - [x] Makefile: `build dev test test-e2e bench fuzz lint example-config release docker-build docker-push compose-up compose-down` (parity) - [x] CI: `lint-test` (golangci-lint + `-race` unit/golden), `e2e` (postgis service + fixture), `docker` (parity) - [x] Release workflow on `v*`: 5-platform cross-compile, checksums, GitHub release, `ghcr.io/suprbdev/pdbr` + `docker.io/suprbdev/pdbr` multi-arch, `act`-aware (parity) diff --git a/docs/migrating-from-postgrest.md b/docs/migrating-from-postgrest.md index d2fe824..9741262 100644 --- a/docs/migrating-from-postgrest.md +++ b/docs/migrating-from-postgrest.md @@ -7,12 +7,12 @@ features are missing. This guide is for people moving a PostgREST v12 or v13 deployment. It lists what maps directly, what differs and what is missing, then a migration order. -> **The 1.0 names are being finalized.** Naming, error codes, operator names, -> mutation shapes and ETags are still being settled before 1.0. This guide -> describes pdbr as it is on `main` today; check [upgrading.md](upgrading.md) -> for what changed between releases and re-run your client tests against the -> version you deploy. The deliberate departures are also listed in -> [features.md](features.md#differences-from-postgrest). +> **Re-check against the version you deploy.** This guide describes pdbr 1.0. +> The URL grammar, error codes, configuration keys and CLI are covered by the +> [1.0 compatibility promise](compatibility.md); check +> [upgrading.md](upgrading.md) for what changed from 0.x and re-run your +> client tests against the version you deploy. The deliberate departures are +> also listed in [features.md](features.md#differences-from-postgrest). Two facts shape everything else: pdbr compiles each request to **one SQL statement** that returns the response JSON, and it is a single Go binary @@ -34,7 +34,9 @@ Maps directly: `Prefer: count=exact|planned|estimated`, `HEAD`, CSV output (`Accept: text/csv`). - JSON bodies for `POST`, `PATCH`, `PUT` and `DELETE`, `Prefer: return=`, `Prefer: resolution=merge-duplicates|ignore-duplicates`, `on_conflict=`, - `columns=`, `Prefer: max-affected=`, `Prefer: tx=rollback`. + `columns=`, `Prefer: max-affected=` (with `handling=strict`, as in + PostgREST) and `Prefer: tx=rollback` (needs `transactions.end: + commit-allow-override` or `rollback-allow-override`, as `db-tx-end` does). - `GET` for stable and immutable RPC functions, `POST` for volatile ones, named arguments, computed columns (functions taking a row type). @@ -89,7 +91,9 @@ fallback): unless `mutations.allow_unfiltered: true`, as with the `pg-safeupdate` extension. - **`PUT` on a row path (`/users/1`) is a partial upsert.** PostgREST needs every - column in the body; pdbr keeps the columns you do not send. + column in the body; pdbr keeps the columns you do not send on update. The + statement is still an insert-or-update, so a `NOT NULL` column without a + default must be in the body (`400 invalid_body` otherwise). - **`Prefer: missing=default` is a no-op**: pdbr always inserts `DEFAULT` for omitted keys in bulk bodies. - **ETags** are weak and computed in SQL on single-row reads @@ -137,8 +141,12 @@ Differences to plan for: - **The authenticator role must inherit the request roles.** pdbr introspects with the connection role's own privileges, so a `NOINHERIT` authenticator (PostgREST's recommendation) sees no tables. Create it with the default - `INHERIT`, as in [Secure setup](quickstart.md#secure-setup). Or dump a schema - cache as a privileged role and boot from it ([caching.md](caching.md)). + `INHERIT`, as in [Secure setup](quickstart.md#secure-setup). On PostgreSQL 16 + and later the inherit flag is recorded per membership when the role is + granted, so `ALTER ROLE authenticator INHERIT` does not change existing + grants: re-run `GRANT TO authenticator WITH INHERIT TRUE`. + Or dump a schema cache as a privileged role and boot from it + ([caching.md](caching.md)). - Set `roles.allowed` to the roles tokens may name. ## OpenAPI diff --git a/docs/quickstart.md b/docs/quickstart.md index 8c881b9..66962b6 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -3,10 +3,11 @@ ## With the bundled dev stack ```console +$ git clone https://github.com/suprbdev/pdbr && cd pdbr $ make dev # or: make compose-up (detached) … make compose-down ``` -This builds the image and starts PostgreSQL (`postgis/postgis:16-3.4`) with +This builds the image and starts PostgreSQL (`postgis/postgis:18-3.7`) with the demo schema (users, posts, comments, places, events, a `metrics` view and a handful of functions — the same fixture pdbcore ships for both pdbq and pdbr, mounted from `db/init/01-schema.sql`, which `make fixture` regenerates @@ -50,7 +51,7 @@ $ curl -si localhost:8080/posts \ -H 'Content-Type: application/json' \ -d '{"author_id":1,"title":"Hello","published":true}' HTTP/1.1 201 Created -Location: /posts/4 +Location: /posts/5 ... # call a function @@ -67,7 +68,7 @@ Errors come back as RFC 9457 problem details ```console $ curl -s 'localhost:8080/users?nope=eq.1' -{"type":"about:blank","title":"Bad Request","status":400,"detail":"unknown column \"nope\"","instance":"/users","code":"unknown_column"} +{"type":"about:blank","title":"Bad Request","status":400,"detail":"unknown column \"nope\" on \"users\"","instance":"/users","code":"unknown_column"} ``` Because watch mode is on, `ALTER TABLE`/`CREATE TABLE` in the database is @@ -114,7 +115,10 @@ The SQL is identical for pdbq. request roles: pdbr introspects with the connection role's own privileges, so a table that role cannot reach would not get a route (do not create it `NOINHERIT` as for PostgREST). Each request then runs `SET LOCAL ROLE` to - the role in its token. + the role in its token. Run this in a database cluster of its own: the + bundled dev stack's fixture already creates an `anonymous` role, so + `CREATE ROLE anonymous` fails there with `role "anonymous" already exists` + (drop that line to reuse the role). ```sql CREATE ROLE authenticator LOGIN PASSWORD 'change-me'; diff --git a/docs/upgrading.md b/docs/upgrading.md index 1bcbe91..5d374e2 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -183,7 +183,8 @@ Loading a config or environment that uses an old key fails and names the new one (`unknown key server.tx_end: moved to transactions.end`, `unknown environment variable PDBR_SERVER_MAX__COST (server.max_cost): moved to PDBR_LIMITS_MAX__COST`); flags are renamed the same way -(`--server.tx_end` is `--transactions.end`). +(`--server.tx_end` is `--transactions.end`), but an old flag is only rejected +as `unknown flag` without a suggestion: use the table below. - **`server.base_path` defaults to `""`** (was `/api`): the API is mounted at the root, as in PostgREST, so `GET /api/users` is now `GET /users` and