feat(postgrest)!: carry primary keys and relation columns on PostgrestTable and emit them from typegen - #1858
Merged
spydon merged 0 commit intoSep 18, 2026
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
spydon
force-pushed
the
lukasklingsbo/sdk-1886-typed-table-executor-and-client-plugins
branch
from
September 18, 2026 15:15
fd180d5 to
0917c3f
Compare
spydon
deleted the
lukasklingsbo/sdk-1895-table-primary-keys-and-relations
branch
September 18, 2026 15:15
spydon
force-pushed
the
lukasklingsbo/sdk-1895-table-primary-keys-and-relations
branch
from
September 18, 2026 15:15
398d45e to
d4b7bec
Compare
spydon
changed the base branch from
lukasklingsbo/sdk-1886-typed-table-executor-and-client-plugins
to
main
September 18, 2026 15:15
spydon
restored the
lukasklingsbo/sdk-1895-table-primary-keys-and-relations
branch
September 18, 2026 15:16
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.
Stacked on #1857. Tracked in SDK-1895, part of RFC: Pluggable offline support for the client SDKs.
What
PostgrestTableonly knew its name and row converter.supabase_typegenintrospected primary keys but its metadata parser dropped them, and the generated relation constants carried only the embed name. Anything that identifies or joins rows on the client (an offline store, a local evaluator for embedded selects, the typed.stream()primary key) had to be told what the schema already knows.postgrest
PostgrestTable(name, rowFromJson, {required primaryKey, relations = const []}).primaryKeyis the list of typed key columns, empty for a view or a keyless table.relationslists the table's relations.PostgrestRelation<Row, Target>sealed base withname,columns(on this table),referencedTableandreferencedColumns(on the target, paired by index).PostgrestToOneRelationandPostgrestToManyRelationextend it and require all of them.relationthey were projected through instead of only its name.supabase_typegen
primaryKeysintoTableDescription.primaryKey, in key order and per schema.primaryKey:andrelations:on every table definition andcolumns:,referencedTable:andreferencedColumns:on every relation constant, referencing the column constants of both namespace classes. Member identifiers are now claimed once per table up front so cross-table references resolve to the same sanitized names. Goldens regenerated.Breaking changes
PostgrestTable,PostgrestToOneRelationandPostgrestToManyRelationhave required named parameters. All are@experimentalon the v3 line; hand-written definitions in the repository's tests were updated.Tests
postgrest_embedded_relation_test.dart: relations expose the columns of both sides, projected columns keep their relation.generator_metadata_parser_test.dart: primary keys parsed in key order, views have none, composite keys keep their order, other schemas are ignored.dart_generator_test.dart: table definitions list primary key and relations, relation constants carry their columns, a view has an empty key, a sanitized key column keeps its constant.