feat(postgres-adapter): implement IDbAdapter contract (Phase 3a) - #7
Closed
ihistand wants to merge 1 commit into
Closed
feat(postgres-adapter): implement IDbAdapter contract (Phase 3a)#7ihistand wants to merge 1 commit into
ihistand wants to merge 1 commit into
Conversation
Rewrites cli/api/dbadapters/postgres.ts so it compiles against the
modern IDbAdapter interface, and wires the BUILD targets so the file
is part of the //cli/api library again (drops the Phase 2 excludes).
Interface alignment per docs/postgres_first_class_design.md §6 +
docs/postgres_reintegration_assessment.md §Phase 3:
- credentials sqlanvil.IJDBC → sqlanvil.IPostgresConnection
(new proto from Phase 3c)
- execute() returns IExecutionResult { rows, metadata }
— was raw any[]
- executeRaw() new, returns IExecutionResultRaw { rows,
schema, metadata } — schema kept empty (we
lean on the catalog query path for shape)
- withClientLock() callback receives an IDbClient with both
execute() and executeRaw() shimmed over the
underlying pg pool client
- schemas(database) now takes the database arg (ignored, since
Postgres is database-scoped), and filters
pg_catalog / pg_toast / pg_internal /
information_schema
- tables(database, schema) returns ITableMetadata[] (was ITarget[]) —
hydrates full metadata per row. Optional
schema filter is supported.
- deleteTable(target) new — transactional `drop table|view if exists
... cascade` keyed on the actual catalog type
- setMetadata() guards against null actualMetadata (table
doesn't exist yet) instead of crashing
Modernization (assessment doc §Phase 5):
- Drop SSHTunnelProxy block — Supabase + most managed Postgres serve
TLS on a public TCP port; SSH tunnel is no longer needed. The
SSHTunnelProxy class was deleted upstream in commit b4d2b2f.
- Drop parseRedshiftEvalError — replaced with parsePostgresEvalError in
cli/api/utils/error_parsing.ts. pg errors carry `.position` (byte
offset) but not line/column, so we preserve the message only.
- Drop preview() — wasn't in IDbAdapter.
SSL handling tightened:
ssl_mode = "disable" → no TLS
ssl_mode = "verify-ca"|"verify-full" → strict cert verification
ssl_mode = "" | "require" | "prefer" | "allow"
→ TLS with rejectUnauthorized=false
(matches default Supabase / RDS UX)
BUILD wiring:
- cli/api/BUILD: drop `dbadapters/postgres.ts` exclude; add `@npm//pg`
and `@npm//@types/pg` deps.
- cli/api/utils/BUILD: drop `postgres.ts` exclude; add `@npm//pg`,
`@npm//@types/pg`, `@npm//pg-query-stream` deps.
Verified:
./scripts/docker-bazel build //cli/api/... → 8 targets, success
./scripts/docker-bazel build //... → 139 targets, success
./scripts/docker-bazel test //... → 38/41 pass (same 3
pre-existing failures: 2× missing BQ creds, 1× projects.spec
`warehouse` validation issue — none regressed by this PR)
Next phase (Phase 3b): Postgres SQL generator under
core/compilation_sql/postgres/ — one generator per action type with
golden-output tests.
3 tasks
Collaborator
Author
|
Superseded: the Postgres reintegration + Dataform→SQLAnvil rename landed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 3a of `adapter/postgres-first-class` per `docs/postgres_first_class_design.md` §6 + the assessment doc Phase 3 / Phase 5.
Rewrites `cli/api/dbadapters/postgres.ts` so it compiles against the modern `IDbAdapter` interface, and wires the BUILD targets so the file is part of `//cli/api` again (drops the Phase 2 excludes).
Interface alignment
Modernization (assessment doc §Phase 5)
SSL handling
BUILD wiring
`cli/api/BUILD`:
`cli/api/utils/BUILD`:
Verification
```bash
./scripts/docker-bazel build //cli/api/... # → 8 targets, success
./scripts/docker-bazel build //... # → 139 targets, success
./scripts/docker-bazel test //... # → 38/41 pass
```
Same 3 pre-existing failures (2× missing BQ creds, 1× projects.spec `warehouse` validation) — none regressed by this PR.
Stack
Stacked on PR #6 (`adapter/postgres-proto-additions`). Merge order: #1 → #2 → #3 → #4 → #5 → #6 → this.
Next
Phase 3b — Postgres SQL generator under `core/compilation_sql/postgres/` with golden-output tests per action type.
Test plan
🤖 Generated with Claude Code