Skip to content

Drizzle acceptance: 50-line program against real Postgres via @perryts/postgres #488

@proggeramlug

Description

@proggeramlug

Scope

Closes the first + second bullets of #420's acceptance list:

  • Schema definition + insert/select/update/delete + a relation join in a 50-line program compiles via `perry compile`, produces a single-file native binary, runs against a real Postgres, and matches the same program under `node --experimental-strip-types`.
  • One of: pg, mysql2, sqlite drivers verified end-to-end. Others as follow-up.

Driver choice: @perryts/postgres (pure-TS)

Use `@perryts/postgres` (pure-TS Postgres wire-protocol driver, lives at `PerryTS/postgres` repo) instead of the native `pg` (perry-ext-pg). Reason: perry's `compilePackages` story works best when the whole dep tree is pure TS — drizzle + driver + perry-stdlib net.Socket. perry-ext-pg uses sqlx under the hood and bypasses perry's net pipeline; @perryts/postgres exercises the full `import 'net' → net.Socket → wire protocol` path that perry already supports end-to-end.

What's done as of v0.5.585

  • `import { sql } from 'drizzle-orm'` works
  • `import { pgTable, serial, text, integer } from 'drizzle-orm/pg-core'` works
  • 6-line schema definition compiles + runs (v0.5.576 duplicate-symbol fix on `__perry_wrap_perry_unknown_func`)

What's left

  1. Wire `@perryts/postgres` as drizzle's pg driver in a new `test-drizzle-min.ts`.
  2. 50-line program: schema (`pgTable users` + `pgTable posts` with FK), insert + select + update + delete + relation join via `leftJoin`.
  3. Run against a real Postgres on `127.0.0.1:5432` (CI fixture or locally-run `docker run -p 5432:5432 postgres`).
  4. Diff binary output against `node --experimental-strip-types test-drizzle-min.ts`.
  5. Land any compile-time + runtime fixes uncovered along the way under this issue.

Likely shake-out areas

  • Type-level query DSL (heavy generics) — perry uses SWC for parsing so should be fine, but worth a real test.
  • Drizzle's `pg-core` hands off to the underlying client. Verify the `sql` template literal lowers correctly when used through drizzle's internals.
  • Connection pool semantics (drizzle uses persistent connections) interact with @perryts/postgres's own connection-state machine.

Blocked on

If hono's #485 (class-field inheritance across compilePackages) reproduces in drizzle's prototype-mutation patterns, fix that first. Drizzle is more value-oriented than class-oriented though, so probably doesn't hit this — but verify.

Note: perry-ext-pg can stay around for users who want sqlx perf without touching their app code; the well-known table routes `import 'pg'` to it. Drizzle just gets a different default-stack for its end-to-end demo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions