Skip to content

Add PostgreSQL 19 support - #44

Merged
gmr merged 2 commits into
mainfrom
pg19-support
Jul 22, 2026
Merged

Add PostgreSQL 19 support#44
gmr merged 2 commits into
mainfrom
pg19-support

Conversation

@gmr

@gmr gmr commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

Adds PostgreSQL 19 support: bumps tree-sitter-postgres to 19.0.0-beta.2 and formats the new PG19 syntax across all eight styles, with a Docker-based round-trip harness that validates the pg_dump style against genuine deparser output.

Features

  • SQL/PGQ property graphs
    • CREATE PROPERTY GRAPH — column-aligned for the river family (river/aweber/mattmc3), one element per line for the left-aligned styles (dbt/mozilla/gitlab/kickstarter), and byte-for-byte pg_get_propgraphdef for pg_dump.
    • ALTER PROPERTY GRAPHADD VERTEX/EDGE TABLES reuses the CREATE block layout (each clause prefixed with ADD); the short DROP ... TABLES and ALTER ... TABLE ... LABEL forms stay on one line.
  • GRAPH_TABLE queries — laid out as an indented block (graph name, MATCH, COLUMNS each on their own line), anchored to the FROM content column for river styles.
  • FOR PORTION OF temporal UPDATE/DELETE preserved.
  • Window null treatment (RESPECT/IGNORE NULLS) and ordered-set WITHIN GROUP — both were previously dropped; now emitted in grammar order alongside FILTER/OVER.

pg_dump fidelity

CREATE/ALTER PROPERTY GRAPH match what pg_dump actually emits — the pg_get_propgraphdef body with one element per line, terminated with a semicolon. Verified against a real PostgreSQL 19beta2 server.

Test harness

  • compose.yaml stands up a throwaway postgres:19beta2 container that loads tests/fixtures/pg_dump/schema.sql on boot. generate.sh captures the deparser output into the pg_dump idempotency fixtures, replacing the previous local initdb/pg_ctl path — now only Docker is required (just gen-pgdump-fixtures).
  • New idempotency fixtures for property graphs, IGNORE NULLS, and WITHIN GROUP. The existing 29 view/function fixtures regenerate byte-identical under PG19.
  • Dedicated per-style smoke assertions for GRAPH_TABLE, CREATE PROPERTY GRAPH, and ALTER PROPERTY GRAPH (table-driven, exact-match, with idempotency checks on the multi-line blocks).

Notes

  • No new general-purpose SQL operators in PG19; the grammar's new ->/| are SQL/PGQ path/label operators, and operators are formatted generically (verbatim passthrough) so they are style-independent.
  • The : label shorthand ((a:Person)) is rejected by PG19 itself — only (a IS Person) is valid, which formats cleanly.

Test plan

  • cargo test — full suite green (smoke suite 23 tests)
  • cargo clippy --all-targets -- -D warnings clean
  • cargo fmt --check clean
  • just gen-pgdump-fixtures reproduces committed fixtures byte-for-byte
  • Feature acceptance verified directly against PostgreSQL 19beta2

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added PostgreSQL 19 formatting support for property graphs (CREATE/ALTER PROPERTY GRAPH), graph queries (GRAPH_TABLE), and additional aggregate/window clause combinations (WITHIN GROUP, FILTER, RESPECT/IGNORE NULLS).
    • Added support for UPDATE/DELETE ... FOR PORTION OF ... targets (including optional FROM ... TO ... forms).
  • Bug Fixes
    • Improved SQL formatting preservation and casing/order for FILTER/WITHIN GROUP/RESPECT|IGNORE NULLS alongside OVER.
  • Tests
    • Expanded PG19 smoke/regression coverage for formatting across multiple output styles.
  • Chores
    • Updated fixture generation to use a temporary Docker-based PostgreSQL 19 environment and refreshed related fixtures.

Update tree-sitter-postgres to 19.0.0-beta.2 and format the new PG19
syntax across all styles.

Features:
- SQL/PGQ property graphs: CREATE PROPERTY GRAPH (aligned for the river
  family, one-per-line for left-aligned styles, deparser-exact for
  pg_dump) and ALTER PROPERTY GRAPH (ADD ... TABLES reuses the CREATE
  block layout; short DROP/label forms stay single-line).
- GRAPH_TABLE queries laid out as an indented block per style.
- FOR PORTION OF (temporal UPDATE/DELETE) preserved.
- Window null treatment (RESPECT/IGNORE NULLS) and ordered-set
  WITHIN GROUP, both previously dropped, now emitted in grammar order.

pg_dump fidelity:
- CREATE/ALTER PROPERTY GRAPH match pg_dump's actual output
  (pg_get_propgraphdef body, one element per line, terminated with a
  semicolon).

Test harness:
- compose.yaml stands up a throwaway PostgreSQL 19beta2 container that
  loads tests/fixtures/pg_dump/schema.sql; generate.sh captures the
  deparser output into the pg_dump idempotency fixtures (replacing the
  local initdb/pg_ctl path, so only Docker is required).
- New fixtures for property graphs, IGNORE NULLS, and WITHIN GROUP.
- Dedicated per-style smoke assertions for GRAPH_TABLE, CREATE PROPERTY
  GRAPH, and ALTER PROPERTY GRAPH.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ba374e7a-c6fe-460f-8ef9-e3a1963f8e5a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The formatter now supports PostgreSQL 19 aggregate clauses, temporal UPDATE/DELETE targets, SQL/PGQ graph syntax, and property graph statements. Fixture generation runs against PostgreSQL 19 beta in Docker Compose, with expanded idempotency and smoke-test coverage.

Changes

PostgreSQL 19 formatting

Layer / File(s) Summary
PostgreSQL 19 fixture infrastructure
Cargo.toml, Justfile, compose.yaml, tests/fixtures/pg_dump/*, tests/pgdump_idempotency_test.rs
The parser dependency and fixture workflow target PostgreSQL 19 beta, with Docker-backed capture of views, functions, and property graph definitions.
Aggregate clauses and temporal targets
src/formatter/expr.rs, src/formatter/stmt.rs, tests/fixtures/pg_dump/view_*.sql, tests/smoke_test.rs
Formatting now preserves WITHIN GROUP, FILTER, RESPECT/IGNORE NULLS, and FOR PORTION OF syntax with style-specific casing and layout.
SQL/PGQ graph formatting
src/formatter/expr.rs, src/formatter/pgdump.rs, src/formatter/stmt.rs, tests/fixtures/pg_dump/propgraph_*.sql, tests/smoke_test.rs
GRAPH_TABLE, CREATE PROPERTY GRAPH, and ALTER PROPERTY GRAPH receive dedicated formatting and pg_dump dispatch, with coverage for paths, labels, aliases, layouts, and idempotency.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SQLInput
  participant Formatter
  participant StyleRenderer
  SQLInput->>Formatter: PostgreSQL 19 SQL
  Formatter->>StyleRenderer: parsed clauses and graph nodes
  StyleRenderer->>SQLInput: formatted SQL for selected style
Loading

Possibly related PRs

  • gmr/libpgfmt#1: Extends formatter areas later expanded here for PG19 graph syntax and statement dispatch.
  • gmr/libpgfmt#4: Modifies the same function-expression handling used for OVER (...) clause formatting.

Poem

I hop through graphs where labels gleam,
And format windows in a stream.
Docker brews the fixtures bright,
Clauses line up neat and right.
PostgreSQL nineteen—what a sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding PostgreSQL 19 support across grammar, formatting, and fixtures.
Docstring Coverage ✅ Passed Docstring coverage is 85.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Cargo.toml`:
- Line 14: Update the tree-sitter-postgres dependency requirement in Cargo.toml
to use an exact version constraint for 19.0.0-beta.2, preventing compatible
prerelease updates while preserving the required grammar version.

In `@compose.yaml`:
- Around line 19-20: Update the fixture database port mapping in the Compose
service to bind host port 5599 specifically to 127.0.0.1 while retaining
container port 5432, preventing exposure on all host interfaces.

In `@tests/fixtures/pg_dump/propgraph_min.sql`:
- Around line 1-4: Add propgraph_min.expected for
tests/fixtures/pg_dump/propgraph_min.sql#L1-L4 and propgraph_shop.expected for
tests/fixtures/pg_dump/propgraph_shop.sql#L1-L8, containing the expected
formatted output, and update the fixture assertions to compare each .sql input
against its corresponding .expected file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e4c4cb29-790b-4f28-9ab1-23f2d2616a34

📥 Commits

Reviewing files that changed from the base of the PR and between 54228ab and 2c11e3a.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • Cargo.toml
  • Justfile
  • compose.yaml
  • src/formatter/expr.rs
  • src/formatter/pgdump.rs
  • src/formatter/stmt.rs
  • tests/fixtures/pg_dump/generate.sh
  • tests/fixtures/pg_dump/propgraph_min.sql
  • tests/fixtures/pg_dump/propgraph_shop.sql
  • tests/fixtures/pg_dump/schema.sql
  • tests/fixtures/pg_dump/view_nulls_win.sql
  • tests/fixtures/pg_dump/view_within_group.sql
  • tests/pgdump_idempotency_test.rs
  • tests/smoke_test.rs

Comment thread Cargo.toml Outdated
Comment thread compose.yaml Outdated
Comment thread tests/fixtures/pg_dump/propgraph_min.sql
- Cargo.toml: use `=19.0.0-beta.2` so a compatible prerelease update
  cannot silently move the tree-sitter-postgres grammar shape.
- compose.yaml: bind the throwaway fixture database to 127.0.0.1 so it
  is not exposed on all host interfaces with committed credentials.

Addresses CodeRabbit review feedback on PR #44.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gmr

gmr commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

🤖 This comment was posted by Claude on behalf of @gmr

Addressed all CodeRabbit review feedback in d173e80:

  • Cargo.toml (Minor): Pinned tree-sitter-postgres to =19.0.0-beta.2 so a compatible prerelease update cannot silently move the grammar shape.
  • compose.yaml (Major): Bound the throwaway fixture database to 127.0.0.1:5599:5432 so it is not exposed on all host interfaces with committed credentials.
  • pg_dump fixtures (Major): Respectfully disagreed. tests/fixtures/pg_dump/ uses a byte-idempotency harness (pgdump_idempotency_test.rs), not the .sql/.expected pairing convention. Each fixture is genuine deparser output compared against itself, so propgraph_min.sql and propgraph_shop.sql are already fully asserted. Adding .expected partners would be redundant and inconsistent with the other 30+ fixtures here.

All three threads resolved. cargo build, cargo test, and cargo clippy -- -D warnings pass locally.

@gmr

gmr commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

🤖 This comment was posted by Claude on behalf of @gmr

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

@gmr: Reviewing the PostgreSQL 19 support changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gmr

gmr commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

Automated monitoring complete — this PR is ready to merge.

  • CI/CD (GitHub Actions): all checks green (cargo test, cargo clippy -- -D warnings, cargo fmt --check).
  • CodeRabbit: re-reviewed HEAD (d173e80), 0 actionable comments, all review threads resolved.
  • Changes applied this session: pinned Cargo.toml tree-sitter-postgres to =19.0.0-beta.2, bound compose.yaml to 127.0.0.1.

No outstanding review feedback or failing checks.

@gmr
gmr merged commit e4e8b7a into main Jul 22, 2026
5 checks passed
@gmr
gmr deleted the pg19-support branch July 22, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant