Repository navigation
Conversation
Port @supabase-labs/tanstack-db (supabase/tanstack-db@245600c) into the monorepo as @tanstack/supabase-db-collection. queryOnce, e2e tests and docs follow in separate PRs; the package stays private until the docs PR. On top of the upstream source: - syncMode: 'eager' option (default 'on-demand') - per-column parse/serialize converters - multi-page reads also order by the key columns, so ties in the query's order no longer repeat or skip rows; the oversized-IN URL budget accounts for that extra order - QueryClient registry is a WeakMap - X-Client-Info version injected from package.json at build time Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Joining composite key values with '-' gave distinct tuples the same collection key (['', '-'] and ['-', ''] both became '--'), so one row overwrote the other. Composite keys are now a JSON array of the values' string forms. Single-column keys are unchanged. A property test generates pairs of tuples cut from the same text and checks that keys are equal exactly when the tuples are; it fails on the '-' join. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The sync wrapper returned a new `sync: { sync }` object, dropping the
factory query-db-collection attaches to its sync config. Without it a
direct write such as `utils.writeUpsert` on an idle collection threw
SyncNotInitializedError instead of starting sync. Spread the original
sync config and replace only `sync`.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Spreading the query collection's options dropped its DbClient config factory, so `collectionOptions(supabaseCollectionOptions(...))` read through the default QueryClient instead of the client's `queryClient` dependency, and a second DbClient could not reuse the descriptor. Register a factory that rebuilds the whole Supabase config, including the Realtime wrapper, with the client's `queryClient`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…l.any React Native (Hermes) and Safari before 17.4 have no AbortSignal.any, so every read split for an oversized IN list threw a TypeError there. The chunk controller now follows the caller's signal through a listener, keeping the caller's abort reason, and removes the listener when the load settles, including on failure. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The order param dropped each sort's `nulls`. TanStack DB puts nulls first unless told otherwise, while Postgres puts them last for ascending order, so a limited ascending window over a nullable column loaded the wrong rows (e.g. [3, 1] instead of the null rows [2, 4]). Every sort the query asks for now carries `.nullsfirst` or `.nullslast`; the key-column tiebreak is unchanged. A new test compares limited windows over a nullable column, for each direction and null placement, with the same live query over a local-only collection, served by a mock that orders like Postgres. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…stack Port the package's own e2e tests from supabase/tanstack-db (reads, filters, mutations, realtime and realtime filters) and run the shared @tanstack/db-collection-e2e suites against PostgREST and Realtime. - The local Supabase project lives in supabase/, on ports 553xx so it runs alongside Electric. max_rows = 2 makes reads page. - The filters cases read through live queries; the queryOnce cases come with experimental_queryOnce. - The shared case "should maintain query state during data changes" is skipped: local Realtime adds about 500 ms per change, so the live query under test is cleaned up mid-test. - CI runs the suite in a new `supabase` group of the E2E workflow. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Port queryOnce, the query IR serializer, and the IR-to-PostgREST translation from supabase/tanstack-db at 245600c, with their unit tests. The function is exported only as experimental_queryOnce because it reads TanStack DB's internal query representation. Adapted to this repo's IR: descriptor sources, conditional selects, and explicit null placement in the order param. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…executeQuery Restore the upstream queryOnce cases in the reads and filters e2e tests. Each filter case now checks the live query, experimental_queryOnce, and executeQuery paths, each through a fresh collection. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
experimental_queryOnce must resolve to what TanStack DB's queryOnce
resolves to for the same query over the same table state. The oracle
generates table states and aggregate-only queries, runs both against a
local Supabase stack with PostgREST aggregates enabled, and compares the
selected fields.
RED on the ported implementation:
SUPABASE_CLI="pnpm dlx supabase@2.116.0" pnpm exec vitest run \
--config vitest.e2e.config.ts e2e/query-once-aggregate-oracle.e2e.test.ts
Counterexample: rows [], sum(id)
expected [ { sum_id_0: null } ] to strictly equal []
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…anStack DB experimental_queryOnce returned PostgREST's aggregate row as-is, so its result depended on the route: SQL returns a row for an empty match, a null sum, and an average over non-null values, while TanStack DB returns no row, sums a null as 0, and averages over every row. min and max compared text by collation and ignored parse conversions, and paging or an unpushable filter changed the outcome. The server path now takes only count, sum, and avg of plain columns, with every filter pushable and no paging, ordering, or distinct. It requests a hidden row count and each average as a sum, and maps the result to TanStack DB's rules. Every other query runs through TanStack DB's queryOnce. - Law: experimental_queryOnce resolves to TanStack DB's queryOnce result over the same table state (IFCS-154). Rows are compared on the select's aliases (maintainer decision, 2026-11-11). - Reach (fixed seed 20261022, 40 histories): server-route 22, server-empty-match 12, server-null-value 8, server-find-one 10, server-subquery-source 12, client-route 33, converted-column 13, limit-or-offset 19, unpushable-filter 6. Four random campaigns reached every state. - RED (port, 173400d): rows [], sum(id): expected [ { sum_id_0: null } ] to strictly equal []. - GREEN: SUPABASE_CLI="pnpm dlx supabase@2.116.0" pnpm test:e2e passes 161 tests (1 skipped). - Mutants, each rejected by an assertion: SQL row on empty input, null sum, SQL avg, min/max pushed, no pushability check, sum over a parsed column, paging pushed, subquery filters dropped. - Limits: min/max are generated only over non-text columns, because TanStack DB's own result over text with nulls depends on row order (recorded in the reusable-law backlog); one local stack and table. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Contributor
Pre-merge checks:
|
2 of 3 tasks
KyleAMathews
added a commit
that referenced
this pull request
Dec 1, 2026
#2507) * feat(supabase-db-collection): add Supabase collection Port @supabase-labs/tanstack-db (supabase/tanstack-db@245600c) into the monorepo as @tanstack/supabase-db-collection. queryOnce, e2e tests and docs follow in separate PRs; the package stays private until the docs PR. On top of the upstream source: - syncMode: 'eager' option (default 'on-demand') - per-column parse/serialize converters - multi-page reads also order by the key columns, so ties in the query's order no longer repeat or skip rows; the oversized-IN URL budget accounts for that extra order - QueryClient registry is a WeakMap - X-Client-Info version injected from package.json at build time Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(supabase-db-collection): encode composite keys unambiguously Joining composite key values with '-' gave distinct tuples the same collection key (['', '-'] and ['-', ''] both became '--'), so one row overwrote the other. Composite keys are now a JSON array of the values' string forms. Single-column keys are unchanged. A property test generates pairs of tuples cut from the same text and checks that keys are equal exactly when the tuples are; it fails on the '-' join. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(supabase-db-collection): keep query collection sync hooks The sync wrapper returned a new `sync: { sync }` object, dropping the factory query-db-collection attaches to its sync config. Without it a direct write such as `utils.writeUpsert` on an idle collection threw SyncNotInitializedError instead of starting sync. Spread the original sync config and replace only `sync`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(supabase-db-collection): read through a DbClient's queryClient Spreading the query collection's options dropped its DbClient config factory, so `collectionOptions(supabaseCollectionOptions(...))` read through the default QueryClient instead of the client's `queryClient` dependency, and a second DbClient could not reuse the descriptor. Register a factory that rebuilds the whole Supabase config, including the Realtime wrapper, with the client's `queryClient`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(supabase-db-collection): combine abort signals without AbortSignal.any React Native (Hermes) and Safari before 17.4 have no AbortSignal.any, so every read split for an oversized IN list threw a TypeError there. The chunk controller now follows the caller's signal through a listener, keeping the caller's abort reason, and removes the listener when the load settles, including on failure. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(supabase-db-collection): send null placement in the order param The order param dropped each sort's `nulls`. TanStack DB puts nulls first unless told otherwise, while Postgres puts them last for ascending order, so a limited ascending window over a nullable column loaded the wrong rows (e.g. [3, 1] instead of the null rows [2, 4]). Every sort the query asks for now carries `.nullsfirst` or `.nullslast`; the key-column tiebreak is unchanged. A new test compares limited windows over a nullable column, for each direction and null placement, with the same live query over a local-only collection, served by a mock that orders like Postgres. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(supabase-db-collection): add e2e tests against a local Supabase stack Port the package's own e2e tests from supabase/tanstack-db (reads, filters, mutations, realtime and realtime filters) and run the shared @tanstack/db-collection-e2e suites against PostgREST and Realtime. - The local Supabase project lives in supabase/, on ports 553xx so it runs alongside Electric. max_rows = 2 makes reads page. - The filters cases read through live queries; the queryOnce cases come with experimental_queryOnce. - The shared case "should maintain query state during data changes" is skipped: local Realtime adds about 500 ms per change, so the live query under test is cleaned up mid-test. - CI runs the suite in a new `supabase` group of the E2E workflow. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(supabase-db-collection): add experimental_queryOnce Port queryOnce, the query IR serializer, and the IR-to-PostgREST translation from supabase/tanstack-db at 245600c, with their unit tests. The function is exported only as experimental_queryOnce because it reads TanStack DB's internal query representation. Adapted to this repo's IR: descriptor sources, conditional selects, and explicit null placement in the order param. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(supabase-db-collection): read e2e filters through queryOnce and executeQuery Restore the upstream queryOnce cases in the reads and filters e2e tests. Each filter case now checks the live query, experimental_queryOnce, and executeQuery paths, each through a fresh collection. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(supabase-db-collection): add the queryOnce server-aggregate oracle experimental_queryOnce must resolve to what TanStack DB's queryOnce resolves to for the same query over the same table state. The oracle generates table states and aggregate-only queries, runs both against a local Supabase stack with PostgREST aggregates enabled, and compares the selected fields. RED on the ported implementation: SUPABASE_CLI="pnpm dlx supabase@2.116.0" pnpm exec vitest run \ --config vitest.e2e.config.ts e2e/query-once-aggregate-oracle.e2e.test.ts Counterexample: rows [], sum(id) expected [ { sum_id_0: null } ] to strictly equal [] Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(supabase-db-collection): make queryOnce server aggregates match TanStack DB experimental_queryOnce returned PostgREST's aggregate row as-is, so its result depended on the route: SQL returns a row for an empty match, a null sum, and an average over non-null values, while TanStack DB returns no row, sums a null as 0, and averages over every row. min and max compared text by collation and ignored parse conversions, and paging or an unpushable filter changed the outcome. The server path now takes only count, sum, and avg of plain columns, with every filter pushable and no paging, ordering, or distinct. It requests a hidden row count and each average as a sum, and maps the result to TanStack DB's rules. Every other query runs through TanStack DB's queryOnce. - Law: experimental_queryOnce resolves to TanStack DB's queryOnce result over the same table state (IFCS-154). Rows are compared on the select's aliases (maintainer decision, 2026-11-11). - Reach (fixed seed 20261022, 40 histories): server-route 22, server-empty-match 12, server-null-value 8, server-find-one 10, server-subquery-source 12, client-route 33, converted-column 13, limit-or-offset 19, unpushable-filter 6. Four random campaigns reached every state. - RED (port, 173400d): rows [], sum(id): expected [ { sum_id_0: null } ] to strictly equal []. - GREEN: SUPABASE_CLI="pnpm dlx supabase@2.116.0" pnpm test:e2e passes 161 tests (1 skipped). - Mutants, each rejected by an assertion: SQL row on empty input, null sum, SQL avg, min/max pushed, no pushability check, sum over a parsed column, paging pushed, subquery filters dropped. - Limits: min/max are generated only over non-text columns, because TanStack DB's own result over text with nulls depends on row order (recorded in the reusable-law backlog); one local stack and table. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(supabase-db-collection): import the Supabase collection docs from the pre-split branch Brings the docs page, adapter skill reference, nav, installation, overview, reference-docs generation, and skill entries across unchanged, apart from merge conflicts with main. The next commit updates them to the current code. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(supabase-db-collection): match the docs to the code and publish the package Updates the imported docs to the code in #2376 and #2412: - `experimental_queryOnce` runs only aggregate-only `count`, `sum`, and `avg` on the server, needs `pgrst.db_aggregates_enabled`, and otherwise runs through TanStack DB's `queryOnce`; - collection keys are string forms, and composite keys are JSON arrays; - document `defaultStringCollation`, the `queryClient` default, and use with `DbClient`, replacing the stale "no SSR" note; - React examples use the 1.0 RC `useLiveQuery({ query })` API; - add a section on migrating from `@supabase-labs/tanstack-db`. Removes `private: true` and joins the 1.0 RC line: the package starts at 1.0.0-rc.0 in `pre.json`, and its minor changeset versions it to 1.0.0-rc.1. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(supabase): controlled receiver for experimental_queryOnce server aggregates Move the server-aggregate oracle's grammar, model, driver, and comparison into a shared module that two receivers register through: the local-stack e2e receiver and a new controlled Node receiver whose PostgREST evaluates filters with SQL three-valued logic and SQL aggregates. Add the promised route as a second law, and a foreign-source property for a collection this package did not create. The Node receiver was RED on unchanged production: a count filtered by an equality on a parsed column took the server route, where PostgREST compares the stored text. serverAggregateOf now keeps a filter that reads a parsed column in TanStack DB, as the Collection's own loads already do. The oracle registry and replay manifest also carry the earlier session's uncommitted Supabase entries; the e2e file carries its earlier edits. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): lost HTTP response after a commit in the mutation-confirmation oracle Two deliveries lose the response after the provider committed, alone or followed by the Realtime delivery of the commit. The shared model's rejection after a server write with no confirmation applies: the transaction rejects, the optimistic edit rolls back, and the later Realtime delivery publishes the committed rows. Three mutants fail: handlers that swallow the failed request, and a listener that writes only known rows. Also fixes the owns entry that named a Realtime function that does not exist. The receiver file and the shared model's `supabase` adapter are the earlier session's uncommitted work. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): declare transport-reconnect for the eager live-source receiver realtime-js reports a lost socket to the channel's subscribe callback as CHANNEL_ERROR, keeps the bindings, and reports SUBSCRIBED after the rejoin. The controlled channel reports the same pair, so the shared RECON-1 law now runs on Node and Chromium. Mutants that release the channel on a transient catch-all error, or tear it down on any later error, fail it. The driver file is the earlier session's uncommitted work. Co-authored-by: Isaac <no-reply@databricks.com> * fix(supabase): remove dead branches in the sync wrapper and fill the db.ts gap report Query Collection's sync always returns a handle object, so the wrapper states that once instead of normalizing a bare cleanup function. The Realtime owner check reads the marker's value, the request options of an owned observer are read without a guard Query Collection makes dead, and the sync run's channel state fields are optional instead of null. The routing oracle observes each supplied QueryClient's net mounts at ready and after cleanup, and the owner-replacement oracle records an error thrown into an application observer's subscription. The seed-2413 db.ts sweep goes from 86 killed and 11 gaps to 89 killed and 2 gaps; the two that remain are eager indexing, which only the real PostgREST receiver rejects, and the returned value of a synchronous cleanup. src/db.ts, src/realtime.ts, and both oracle files also carry the earlier session's uncommitted edits. Co-authored-by: Isaac <no-reply@databricks.com> * docs(supabase): record oracle evidence and maintainer decisions The server-aggregate conditions name the parsed-column rule, and the Realtime section documents the rejoin as a known limitation (maintainer decision, 2026-11-30). The coverage map records the controlled queryOnce receiver, the lost-response and reconnect histories, and the db.ts mutant census with its remaining gaps. Both files also carry the earlier session's uncommitted edits. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): receivers for the shared persistence, reload, startup, and Realtime oracles Work from the first part of this thread, committed as it was left, plus four lint fixes for flags assigned inside closures, a dead sync-handle branch, and the browser oracle config added to the package's TypeScript project. Supabase receives the persisted-demand, persisted-demand-peer, persisted-startup, eager-reload, initial-receipt, Realtime receipt, Realtime filter handoff, and patch-concurrency oracles in Node and Chromium, with local-stack e2e receivers for initial read failure, patch concurrency, and filter handoff. The shared conformance suites, browser persistence e2e, Query Collection startup resources, and the adapter oracle runner gain the Supabase entries and the saved-demand Realtime histories. Production changes in the PostgREST filter builders, row conversions, and mutation handlers accompany them. Co-authored-by: Isaac <no-reply@databricks.com> * chore(agents): oracle skills and AGENTS guidance from the Supabase thread Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): generate filters in the queryOnce grammar and fill the query-once.ts gap report The shared server-aggregate grammar never generated a filter: fast-check's `fc.option(filter, { freq: 1 })` builds the nil case every time, so filter states were reached only through constructed builders. With generated filters, dropping the outer where from the server request fails 12 units. The grammar also gains an empty select, a plain column beside the aggregates, an ordered window on the subquery source, an alias named rows, and a whole-row count, each a declared state with generated reach, and the model follows the documented rule that a filter reading a parsed column stays in TanStack DB. Dead branches leave query-once.ts: the empty-array clause test, the null returns, the stripAlias option of the pushability check, and the guards on the aggregate response row and the aggregate argument. The owner-replacement oracle records an undefined channel topic instead of throwing. The seed-2413 sweep of query-once.ts and realtime.ts goes from 212 killed and 27 gaps to 213 killed and 10 gaps, then to 9 with the whole-row count; the rest are a where form the builder never emits here, a defaulted request method, and a JSON-omitted undefined field. The local-stack e2e suite passed here with the stack started by the CLI. Co-authored-by: Isaac <no-reply@databricks.com> * feat(supabase): report a joined Realtime channel's outage to the health tree realtime-js keeps a joined channel and rejoins it on its own when the socket drops or a rejoin fails, reporting each failure to the subscribe callback as CHANNEL_ERROR and the rejoin as SUBSCRIBED. The adapter now reports each such error to the sync run's health while the Collection is ready and clears them on the rejoin, as the other retrying adapters do. Before ready it reports nothing, as core requires. A rejected filtered join and a pending replacement's error still fall back as before. The Supabase eager live-source driver declares retry-policy with retryReportAfter 1 instead of transport-reconnect: for Supabase a socket loss and a retried attempt are the same CHANNEL_ERROR. The controlled channel joins at subscribe time, and a delivery first reports the rejoin. On unchanged production 84 units failed HEALTH-1. With the change both hosts pass; mutants that never report, never clear, or report before ready fail 84, 64, and 9 units. Maintainer decision, 2026-11-30: follow the pattern of the retrying adapters and the shared HEALTH-1 and HEALTH-2 laws. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): controlled Node receiver for the filtered ordered window Move the ordered-window oracle into a shared module that the local-stack e2e receiver and the controlled Node receiver register through. The controlled PostgREST now caps every response at two rows, as the local stack's max_rows = 2 does, so each window pages past the provider cap, and it evaluates the keyset cursors the adapter renders strictly, including the composite cursor of a mixed-order continuation. The aggregate receiver waits for the client to go quiet between queries, since an on-demand load can still be paging when the next query starts. All 116 ordered-window units pass on Node against current production. With createSupabaseConfig in its owns, the Node receiver rejects the removal of eager auto-indexing (db.ts:M39), which only the local stack had rejected. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): controlled receivers answer like PostgREST; remove dead read and write code The controlled PostgREST returns rows tied under the requested order in a different order on every other request, rejects a URL longer than the adapter's budget, and the mutation driver honours Prefer and the object Accept, so paging, URL splitting, and representation requests are judged by their effects. The ordered-window driver records a load that throws as a violation instead of a crash. functions.ts drops the select=* on insert and update, which PostgREST's representation already returns; the parsed-cursor test of the server subset, which the parsed-order test implies; and the single-chunk dispatch, since a load of one chunk is one chunk. The seed-2413 sweep of functions.ts goes from 139 killed, 8 crashed, and 75 gaps to 159 killed, 0 crashed, and 46 gaps; the coverage map groups what remains. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): the abort law is propagation, not signal identity A load of one chunk now runs through the chunk loader, whose requests carry a signal derived from the caller's. The unit test asserts what the law promises: aborting the caller's signal aborts every request's signal with the caller's reason. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): abort the caller's signal while the load is in flight The previous commit's assertion aborted after the load had settled, when the chunk loader has already released its derived signal from the caller's. The caller now aborts during the second page, and every request's signal is aborted with that reason. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): held loads prove cancellation; remove the dead delete guard The controlled PostgREST can hold its responses after a generated number of served reads and answer a held read with a server error. The ordered-window oracle declares three states for receivers with that hold: cleanup during a held oversized chunk load, one chunk failing while its siblings are held, and cleanup during a held keyset continuation. Each requires every held request's signal to be aborted, nothing published or requested after the release, and no detached rejection; the failing chunk also rejects the load. Current production passes all three, and the mutants that drop a request's signal, the sibling abort, or the caller's abort listener fail them. The delete handler's synced-store guard was unreachable: its own mutation is persisting while it runs, so a Realtime echo's direct delete is held until settlement and the row is still synced at the check. The write now reuses the Realtime module's ignoreCancelledWrite, which treats the row's absence as the confirmation it is. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): offset states for the ordered window and the direct adapter load A converted-offset live window loads the whole parsed match and skips locally. Core never sends a non-zero offset to loadSubset, so two direct states call the adapter's query function with an offset: a native predicate applies it on the server, and a parsed predicate loads the whole table and leaves it to the caller. The direct states kill the mutant that keeps the offset on the server for a local predicate. The subset query key's cursor and offset terms remain a Query Collection ownership question, recorded in the coverage map. Co-authored-by: Isaac <no-reply@databricks.com> * feat(supabase): report a timed-out Realtime rejoin as a failed attempt realtime-js reports a rejoin that times out as TIMED_OUT with no error. The eager driver injects it as a second kind of failed attempt; on production that reported only CHANNEL_ERROR, 71 units failed HEALTH-1. The adapter now reports every failed attempt of a joined channel, with an error of its own for a timeout, and its health hooks are required rather than optional. The controlled channel surfaces a status callback that throws as a detached rejection, as the socket handler would, so a health report that throws fails HEALTH-5 instead of crashing the driver; the three crashed health mutants are killed that way. Both hosts pass: 110 Node and 271 Chromium units. Co-authored-by: Isaac <no-reply@databricks.com> * docs(supabase): closing mutant census for the four adapter modules Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): withdrawn demand during a pending join, tied pages, and a dead metadata guard The handoff receiver drives the first demand away while the replacement joins and then the remaining demand too: the joined channel and the pending replacement are both released and a stale status changes nothing. The ordered-window oracle adds a window where every row ties on the order column and spans several two-row pages: the pages must agree, so the window holds limit distinct tied rows. The query function stops guarding request metadata that Query Collection installs on every query it runs. Co-authored-by: Isaac <no-reply@databricks.com> * docs(supabase): record the query-key experiment and the updated census Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): a direct load with an already-aborted signal rejects The controlled fetch rejects a request whose signal is already aborted, as fetch does, and the controlled PostgREST's tie parity restarts with every history so two runs of one history see the same provider. A direct adapter load with an aborted signal must reject; without the chunk loader's pre-abort of its own controller, the requests carry a live signal and the load fulfils with rows. Co-authored-by: Isaac <no-reply@databricks.com> * fix(supabase): apply the CodeRabbit review's confirmed findings Production: the aggregate gate keeps text ranges in TanStack DB, as the Collection's reads do (RED: 7 units took the server route or disagreed under an en-US collation); Realtime subscribes to the client's db.schema (RED: 34 units with a custom schema); releasing a channel clears the outage it reported to health (RED: 4 units in the new handoff scenario); a Date key keeps its milliseconds; an empty key list is rejected at construction, since a DELETE without a row filter would address every row; a filter on a column named like a PostgREST parameter goes in a logic group instead of being clobbered by the sort; the chunk planner keeps a zero limit; a zero-limit cursor load makes no tie read; a conversion skips columns the row does not own; the queryOnce callback runs once; aggregate wire aliases are generated, so a user alias cannot collide with the row count; and the paging comment states the actual guarantee under concurrent writes. Receivers: text ranges and a custom schema in the grammars, en-US text order and type-checked aggregates in the controlled PostgREST, aborted reads leaving the hold queue, a whole-row count recognised as an aggregate request, rows observed across the cancellation boundary, receipt drivers that fail instead of waiting when a read settles without its held commit, and the unit test hardening the review asked for. Docs: Realtime DELETE and RLS, the unfiltered listeners that remain, sub-millisecond Date keys, the parsed-column and text-range filter exceptions, and the install command. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): the catch-all fallback e2e waits for its unfiltered channel The filtered-realtime helper now insists on a filtered binding, which the catch-all fallback never carries, so that test passes `filtered: false`. Observed in the local stack run: 1 failed, 313 passed before; the file is 18 of 18 after. Co-authored-by: Isaac <no-reply@databricks.com> * ci: apply automated fixes * test(supabase): apply the second CodeRabbit review The toString regression changes a real column, so the PATCH exercises serializeRow (RED without the ownership guard: TypeError on Object.prototype.toString; GREEN with it). The initial-receipt driver attaches teardown errors to the observation after both teardown steps ran, on both return paths. The db-core skill reference states the Realtime DELETE exception to RLS, as the collection guide does. The review's e2e finding was already fixed in the previous commit. Co-authored-by: Isaac <no-reply@databricks.com> * build(supabase): declare @playwright/test for the Chromium oracle step The E2E workflow runs `pnpm exec playwright install` in the package before its Chromium receivers, which drive the browser through the shared host in browser-db-sqlite-persistence. The package did not declare Playwright, so CI stopped with "playwright not found" before any test ran. Same version as the db and browser persistence packages; sherif clean; the step passes locally (271 tests). Co-authored-by: Isaac <no-reply@databricks.com> * ci(supabase): build check script and typed doc examples Main now requires every public package to declare `test:build` (publint and attw) and typechecks the guide and skill examples. The package gets the same check as the other collections (all four resolution modes green). Five examples failed the typecheck: the React example imported the collection from an app module the checker cannot type, a mutation example used an untyped id that selected the array overload, the complete example read `import.meta.env`, the DbClient example used `supabaseCollectionOptions` without importing it, and the skill's complete example used an undeclared schema. Each now typechecks against the packages' source; `node scripts/check-doc-snippets.mjs` reports 0 new failures. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): do not spell a mangled private member in comments The mangle cache check reads every source file syntactically, so comments that named `OrderedSourceLoader`'s private boundary method made the entry unsafe. The comments describe the probe in prose instead. Co-authored-by: Isaac <no-reply@databricks.com> * test(supabase): shared drivers build deferreds without Promise.withResolvers The browser persistence package and the adapter conformance package import these drivers, and their TypeScript lib stops at ES2022, so the sqlite-adapters CI group failed its typecheck on `Promise.withResolvers`. The drivers use the db package's `createDeferred`, which has the same shape. The browser package's vitest typecheck and both packages' consuming oracles pass. Co-authored-by: Isaac <no-reply@databricks.com> --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Isaac <no-reply@databricks.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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.
🎯 Changes
Adds
experimental_queryOnce(callback, supabase)to@tanstack/supabase-db-collection(IFCS-154). This is PR 3 of 4.experimental_queryOnce.private: true.What it adds
The port from
supabase/tanstack-dbat245600c:query-once.ts;serializeQueryIRand the query IR types inserialize.ts;postgrest-filters/query-ir-to-search.ts;query-once.test.ts,serialize.test.ts, and thequeryIrToSearchblock).It is exported only as
experimental_queryOnce, because it reads TanStack DB's internal query IR. Changes to fit this repo:ConditionalSelectin a select;order;X-Client-Infoname.The
queryOncee2e cases. Reads gets back its one-shot query. Each filters case now reads through three paths: a live query,experimental_queryOnce, andexecuteQuery. Each path reads through a fresh collection.A server-aggregate oracle against the local stack, plus a migration that enables PostgREST aggregates (
pgrst.db_aggregates_enabled) and adds thequery_once_rowstable.A fix the oracle found. The ported server path returned PostgREST's aggregate row as-is, so a query's answer depended on its route. The table shows each case.
queryOnce[{ count: 0 }][](findOne:undefined)sum/avgnull0avgof[1, null]10.5max(label)overa A b B'B'(collation)'b'parse'9' > '10')limit/offsetwithoutorderBy[]Per the decision on IFCS-154,
experimental_queryOncemust match TanStack DB exactly. The server path now takes onlycount,sum, andavgof plain columns. Every filter must be pushable, and the query can't page, order, or usedistinct. It requests a hiddencount()and asks for each average as a sum, then applies TanStack DB's rules. Every other query, includingmin/max, runs through TanStack DB'squeryOnce.Please look at these
$key,$origin,$hasPendingWrites, and$collectionId, and server rows do not. The oracle compares only the select's aliases. This is a maintainer decision, recorded in the coverage map.0beforemin/max, and'a' < 0and0 < 'a'are both false. Somin(label)over'a', null, nulldepends on row order. The oracle generatesmin/maxonly over columns that hold no text. The defect is in the coverage map's reusable-law backlog.sumgives0, andavgincludes nulls in its row count. The server path reproduces both. If core changes them, the oracle will flag the server path.#28(in245600c) already moved them to the client, and this PR keeps them there.🔬 Oracle Coverage
Owner: the new coverage-map row "Supabase
experimental_queryOnceserver aggregates" (e2e/query-once-aggregate-oracle.e2e.test.ts).Law:
experimental_queryOnceresolves to TanStack DB'squeryOnceresult over an eager Collection of the same table (IFCS-154). Results are compared at the settled promise. Rows are projected to the select's aliases, and a rejection must match a rejection.Reach, fixed seed
20261022, 40 histories:server-routeserver-empty-matchserver-null-valueserver-find-oneserver-subquery-sourceclient-routeconverted-columnlimit-or-offsetunpushable-filterFour random campaigns reached every state.
RED on the port (
173400d9b), withSUPABASE_CLI="pnpm dlx supabase@2.116.0" pnpm exec vitest run --config vitest.e2e.config.ts e2e/query-once-aggregate-oracle.e2e.test.ts. Counterexample: rows[]andsum(id)gaveexpected [ { sum_id_0: null } ] to strictly equal [].GREEN:
pnpm test:e2epassed 161 tests with 1 skipped (the existing skip from test(supabase-db-collection): add e2e tests against a local Supabase stack #2400).Mutants: each of these was rejected by an assertion failure:
sum;avg;min/maxpushed to the server;sumover a parsed column;Limits:
min/maxonly over columns that hold no text;✅ Checklist
pnpm test.Unit tests: 705 passed and 18 todo, with no type errors.
pnpm test:e2epassed 161 tests with 1 skipped.pnpm lint:changedis clean.🚀 Release Impact
private: trueuntil PR 4, which adds the changeset.Size: the package's minified gzip bundle grows from 5,482 to 8,142 bytes. The port adds 2,325 of those, mostly the faithfully ported serializer and join-embedding code, which
experimental_queryOncecannot reach. The fix adds 335.pnpm size:comparereports no change for published packages.🤖 Generated with Claude Code