Bidirectional ManyToOne: generate inverse collection + join allowlist - #127
Merged
Conversation
The CLI cloned template main at HEAD, so the @apso/crud version a scaffold got was a date cutoff, not an explicit pairing. Pin the TypeScript template to v2.0.0 — the first revision on published @apso/crud ^1.0.1 (nestjsx + PostgREST dual dialect). Python and Go templates stay on main; their repos are untagged and do not carry the dialect work. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The v2 template ships only @apso/crud* dependencies, but the code generators still emitted @nestjsx/crud imports, so a fresh scaffold + generate produced code that could not resolve its CRUD imports (the source of the v1/v2 base-image mismatch, task #84). Swap the import module paths in the Eta templates — @apso/crud exports every symbol under the same names (import-swap parity). Verified end-to-end: clone template v2.0.0, generate a 2-entity schema with relationships, npm install, nest build — compiles clean against published @apso/crud 1.0.2. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… lint error Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…oin allowlist A declared ManyToOne produced only the FK side, so the target entity had no collection property and no controller join allowlist: the AI schema builder declares Book->ManyToOne->Author, and Authors?join=books (or the PostgREST select=books(title)) was silently dropped in both dialects. Mirror the OneToMany case with the roles swapped: the target now gets the inverse OneToMany property and join. bi_directional: false keeps the old FK-only shape, and self-references stay unidirectional. Verified: 324 tests pass; regenerated a Book->ManyToOne->Author service, compiles clean, and the collection-side embed returns rows in both the nestjsx and PostgREST dialects at runtime. Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
What
A declared
ManyToOnerelationship now generates both sides, mirroring howOneToManyalready works: the target entity gets the inverse collection property and the controller join allowlist.Why
The AI schema builder declares relationships as
Book →ManyToOne→ Author. The parser only generated the FK side, soAuthorhad nobooksproperty and no join allowlist entry —Authors?join=books||title(nestjsx) andAuthors?select=books(title)(PostgREST) were both silently dropped. Found during the staging dual-dialect validation of service 4717.Behavior
OneToManydeclarations).bi_directional: falsekeeps the old FK-only unidirectional shape.OneToMany+ManyToOnepairs dedupe ingetRelationshipForTemplate(same name+referenceName key).Note:
parse.tshas both the live inline switch inparseRelationshipand the older exportedparseManytoOne(only referenced by tests) — both updated to keep them consistent.Verification
Post →ManyToOne→ Authorservice: compiles clean; booted it and the collection-side embed returns rows in both dialects, matching the declared side.Rollout note
Merging publishes a new CLI version via the main workflow. Deployed pairing then needs the usual follow-through: client
APSO_CLI_VERSIONbump. Template tag/TEMPLATE_REFSare unaffected.🤖 Generated with Claude Code