test(database,service): hold every live statement to the immutability Neon Realtime requires
Merged
CH
6d ago+314+314+012345678901234567890123456789-0-0-0123456789
This PR changes no user-visible behaviour. It adds tests only. It's the first of three small Realtime plumbing PRs split out of #3232, so the plumbing can land without any feature attached. Every Realtime PR is on hold, so please don't merge it yet.
What it does
Neon Realtime refuses a statement that calls any function, operator, or aggregate that Postgres doesn't mark immutable ("scalar expression uses a mutable function"). Postgres and PGlite run the same statement without complaint, so the refusal only shows up in production.
mutableFunctionsOf(packages/database/src/testing/live-immutability.ts, exported from@luke/database/testing) turns a statement into a temporary view, reads what the view's rule calls frompg_rewrite, and names every call that isn't immutable. Casts through text are included.live-immutability.test.tscovers the helper itself.live-statements.test.tsruns every statement/api/live/inboxseals onmainthrough the helper: the account inbox's parts and the failed runs. They all pass already.
Stack
- This PR (base
main) - Seal through
drizzleAdapter()(base: this PR) - Shared host follow,
live-follow.ts(base: PR 2) - #3232, the plan and agent scope inbox (base: PR 3)
Made with Luke