Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 18 additions & 10 deletions docs/migrating-from-postgrest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <request role> 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
Expand Down
12 changes: 8 additions & 4 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion docs/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading