Repository navigation
test(postgrest-typegen): exercise the Swift scalar type mappings - #145
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 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. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The test coverage is sound; only minor documentation inaccuracies remain.
Pull request overview
Adds regression coverage for Swift scalar mappings and name formatting.
Changes:
- Adds a scalar fixture and parity goldens for four generators.
- Tests Swift underscore and separator handling.
- Documents unreachable pseudo-type mappings.
File summaries
| File | Description |
|---|---|
test/introspection/fixtures/00-init.sql |
Adds scalar fixture data. |
test/generation/swift.test.ts |
Adds Swift naming tests. |
src/generation/swift.ts |
Documents pseudo-type branches. |
test/parity/expected/swift.txt |
Captures Swift mappings. |
test/parity/expected/go.txt |
Captures Go mappings. |
test/parity/expected/python.txt |
Captures Python mappings. |
test/parity/expected/typescript.txt |
Captures TypeScript mappings. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
grdsdev
approved these changes
Sep 2, 2026
Six reachable branches of the Swift generator were asserted by nothing. Verified by mutation, not by reading the coverage report, since that report has already proven unreliable at line granularity in this package. Four are scalar mappings that no fixture column reached: bool -> Bool, int2 -> Int16, float4 -> Float and float8 -> Double. Nothing in the fixture declared a bool, smallint, real or double precision column, so those arms were never generated. Break int2 -> Int16 before this commit and the whole suite stayed green. A new scalar_type_test fixture table covers them end to end through the parity goldens, following the interval_test precedent of a small table dedicated to pinning a type mapping. Swift and Go both map the integer and float families to distinct widths, so both goldens gain; Python collapses each family onto int and float and is unaffected. The other two are in formatForSwiftTypeName: the leading underscore that has to survive pascal-casing, and the empty words that a leading or trailing separator produces. A run of separators collapses to a single delimiter and produces none. void and record stay untested because they are unreachable rather than missed: they are pseudo-types, and Postgres rejects them as a column or composite attribute type, which is all this generator renders. Verified against a real database and recorded as a comment so the next reader does not chase them.
spydon
force-pushed
the
test/cover-swift-scalar-mappings
branch
from
September 2, 2026 14:58
86ced01 to
795685e
Compare
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.
Closes SDK-1721. Sibling of #144.
What
Six reachable branches of the Swift generator were asserted by nothing. Break
int2 -> Int16before this commit and the whole suite stayed green.Four scalar mappings no fixture column reached:
boolBoolint2Int16float4Floatfloat8DoubleNothing else in the fixture declares a
bool,smallint,realordouble precisioncolumn, so those arms were never generated by any test.Two in
formatForSwiftTypeName: the leading underscore that has to survive pascal-casing (_key_id_context -> _KeyIdContext, which the doc comment promises), and the empty words a leading or trailing separator produces. A run of separators collapses to a single delimiter and produces none, soa--byields two words rather than three.How
A new
scalar_type_testfixture table pins the four scalars end to end through the parity goldens, following theinterval_testprecedent of a small table dedicated to a type mapping. Goldens regenerated for all four languages.Swift and Go both map the integer and float families to distinct widths, so both goldens gain from these columns. Python collapses each family onto
intandfloatand is unaffected either way:The two name-formatting cases are unit tests in
swift.test.ts, since a deliberately mis-named relation belongs there rather than in the shared fixture.voidandrecordstay untested on purposeThey are unreachable, not missed. Both are pseudo-types, and this generator renders only columns and composite attributes. Verified against a real Postgres rather than assumed:
Left in place with a comment explaining why, since they are the right mappings if Swift ever emits functions. They are the only lines still uncovered in the file.
Verified by mutation, not by the coverage report
Every branch above was checked by mutating it and confirming the suite fails. That is deliberate: as #144 documents, bun's line attribution in this package is unreliable, and it once stopped reporting a line as uncovered merely because an unrelated test was added while mutating that line still broke nothing.
Testing
131 pass, 0 fail against a real database, parity gate included.
check-types,oxfmt,oxlint,knip,buildall clean.Golden diff is additive only: +42 Swift, +24 Go, +24 TypeScript, +21 Python, no deletions.
Review follow-up
Three inaccurate comments I had written were caught in review and corrected; all three claims were verified before accepting them. No behaviour changed, comments and one commit message only.
int2/int4/int8andfloat4/float8to distinct widths, exactly as the new Go golden shows. Only Python collapses. The fixture comment claimed otherwise.