Skip to content

refactor(postgrest-typegen): drop the unused postgres-meta options from the introspection - #180

Open
spydon wants to merge 2 commits into
lukasklingsbo/postgrest-typegen-node-tree-rewritesfrom
lukasklingsbo/postgrest-typegen-introspection-cleanup
Open

refactor(postgrest-typegen): drop the unused postgres-meta options from the introspection#180
spydon wants to merge 2 commits into
lukasklingsbo/postgrest-typegen-node-tree-rewritesfrom
lukasklingsbo/postgrest-typegen-introspection-cleanup

Conversation

@spydon

@spydon spydon commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Stacked on #179.

Summary

The introspection SQL builders were ported from postgres-meta's managers together with every option those managers accept: limit, offset, idsFilter, nameFilter, tableIdentifierFilter, viewIdentifierFilter, columnNameFilter, tableIdFilter, the args filter of the functions query and the includeTableTypes/includeArrayTypes flags of the types query. introspect() sets exactly one of them, the schema filter. The builders are not exported from the package and nothing else in the repository passes the other options, so they were unreachable code that still had to be read around.

  • Every builder now takes SchemaFilterProps, a required schemaFilter and nothing else. TYPES_SQL becomes a constant since it had no variable part left.
  • The args block of FUNCTIONS_SQL, a nested ternary interpolating a string[] through Array#toString, goes away together with the file-wide lint suppression it needed.
  • The rendered SQL loses all but one conditional filter line per builder, and with it most of the blank lines with trailing whitespace.
  • introspect() no longer re-filters the schemas rows in JavaScript. The query already applies the same include and exclude filter; the only case where the two differed was a schema listed in both lists, which the JavaScript filter dropped from schemas while every other collection still contained it.
  • introspect() passes the filter it already built to listRelationships instead of having it rebuilt from the options.
  • The cartesian product in expandViewRelationships is a flatMap instead of the gist-linked map/reduce pair.

Verification

  • bun run test with Docker: 133 pass, including the introspection integration tests and the view relationship expansions.
  • SQL snapshots in sql.test.ts regenerated; the diff is the removed blank lines, the constant TYPES_SQL, and the schemas query's unconditional pg_ exclusion.
  • check-types, format-and-lint and knip pass.

Generated output is unchanged for every option combination introspect() can produce, so the byte-parity constraint with postgres-meta holds.

…om the introspection

The SQL builders kept every option of the postgres-meta managers they were
ported from: limit and offset, id and name filters, table identifier
filters, the functions args filter and the types flags. introspect() only
ever sets the schema filter, the builders are not exported, and nothing
else in the repository passes the other options, so they were unreachable.
Each builder now takes the schema filter alone and the types query is a
constant, which also removes the blank filter lines from the rendered SQL
and the lint suppression the args interpolation needed.

introspect() no longer re-filters the schemas rows in JavaScript, since
the query already applies the same include and exclude filter, and passes
the filter it built to listRelationships instead of having it rebuilt.
The cartesian product in the view relationship expansion is a flatMap.
@spydon
spydon requested a review from a team as a code owner September 14, 2026 15:40
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2118ddd1-bbc1-4fad-bb3d-26774127cced


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…lders

Every caller passes it, so an optional field only hides a forgotten filter.
Also drop the removed limit interpolation from the pg-format note.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant