Repository navigation
fix(codegen-ts): derived flattened parent produces no flat member keys - #539
Merged
Merged
Conversation
…ction: derived flattened field owns no columns and exposes no flat keys. CHANGELOG already covered the fix. No other stale docs found.
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.
What Changed
flatSurfaceFieldsandflattenedMembersOfincodegen-tssrc/flattened.tsnow return no members for a flattenedfield.objectthat is derived (carries anorigin.*). The flat keys (for exampleshipToStreet) no longer appear in the read, create and update zod schemas, filter and sort allowlists, OpenAPI bodies, or form. Matches the Drizzle table andmeta migrate, which already create no columns for that parent.docs/features/field-types.mdstates that a derived flattened field owns no columns and exposes no flat keys, and that a write cannot set them.CHANGELOG.mdgains a Fixed entry for the change.test/flattened-storage-e2e.test.tsadds a case with a derived flattened parent. It asserts the surface field list, the Drizzle table columns (id,owner_id,ref), and that no generated Parcel file mentions the flatshipTokeys.Validation
Risk Assessment
✅ Low: One early-return in flattenedMembersOf makes flatSurfaceFields, the Drizzle table, entity-file and every schema/allowlist consumer treat a derived flattened parent as a single non-flattened field, matching drizzle-schema and migrate's expected-schema; the new e2e test exercises the real generator output.
Testing
Drove the real worktree CLI on a disposable project plus OpenAPI and UI descriptor probes. The derived flattened parent produced no flat keys anywhere after the fix, while the old code leaked them. The non-derived flattened control kept its columns and keys. The new regression test fails before the fix and passes after it. The extra
ci-local.sh --quickrun was killed at its background time limit and gave no result either way; I did not restart it. The regression evidence is the pipeline's baseline TS fast and unit run, which passed earlier, plus the targeted test file. Other-language ports and the docker suite were not run; the change touches TypeScript codegen only. No UI is involved, so no screenshots were taken. The worktree is clean and the disposable project was removed.bun server/typescript/packages/cli/bin/meta.ts gen) in a disposable project. Generated Parcel.ts has no flat keys. ParcelInsertSchema and ParcelUpdateSchema hold only ref and o…bun test test/flattened-storage-e2e.test.tsgives 21 pass with the fix. With the old flattened.ts it fails: flatSurfaceFields returned shipToStreet and shipToCity instead of shipTo.Evidence: ci-local --quick log (partial; run was killed at its time limit, no EXIT line)
Evidence: Before/after OpenAPI + UI probe
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bun server/typescript/packages/cli/bin/meta.ts gen) in a disposable project. Generated Parcel.ts has no flat keys. ParcelInsertSchema and ParcelUpdateSchema hold only ref and o…bun test test/flattened-storage-e2e.test.tsgives 21 pass with the fix. With the old flattened.ts it fails: flatSurfaceFields returned shipToStreet and shipToCity instead of shipTo.scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchainsbun test test/flattened-storage-e2e.test.tsin codegen-ts, with and without the fixWorktreemeta eject+meta gen(run from source) on a disposable project with a derived flattened parent, a replica view, and a non-derived flattened controlThrowaway bun test probing buildOpenApiDocument and buildEntityUiDescriptor before and after the fixscripts/ci-local.sh --quick --strict-toolchains(killed at the background time limit; no result)Baseline already run by the pipeline:scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchains(passed)server/typescript/packages/codegen-ts/src/flattened.ts:54- Judgment for outer executor: the doc edit assumes flatSurfaceFields goes through flattenedMembersOf. asFlatKey still forwards the member's isDerived() rather than the parent's. Confirm that path is unreachable for a derived parent, or add the parent check there too.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.