refactor(service,database): seal live statements through Neon's drizzleAdapter()
Merged
CH
7d ago+140+140+012345678901234567890123456789-16-16-01234567890123456789
This PR changes no user-visible behaviour. A subscription delivers the same rows as before; only the way the service seals a statement changes. It's the second of three Realtime plumbing PRs split out of #3232, stacked on #4071. Every Realtime PR is on hold, so please don't merge it yet.
What it does
Neon's guide seals a Drizzle select through its Drizzle adapter, not through raw SQL built from toSQL().
LiveStatement.query: a live statement now carries the Drizzle select it was rendered from (LiveSelect). A statement that binds aDatedoesn't carry it, because the adapter encodes noDate.live/realtime.ts: the sealer callscreateRealtime({ adapter: drizzleAdapter() })and sealsstatement.query. A statement written as text alone, like the tests' stand-ins, still falls back torawSql. The adapter also refuses a select whose key isn't the name Postgres answers the column under.- Dependencies:
@neon/realtime-drizzleis pinned at0.1.0. Its declareddrizzle-ormpeer is>=0.45.2 <0.46.0, but it only reads what1.0.0-rc.4builds the same way, sopnpm-workspace.yamladds apeerDependencyRulesentry allowing that version. - Tests:
realtime.test.tschecks that the adapter takes aliveSelectionselect and refuses a renamed key.live-statements.test.tsnow also seals every statement/api/live/inboxseals through the adapter.
Stack
- #4071, the immutability test helper (base
main) - This PR
- Shared host follow,
live-follow.ts(base: this PR) - #3232, the plan and agent scope inbox (base: PR 3)
Made with Luke