fix: use entity field names in CLI delete select instead of PK constraint names#1329
Open
pyramation wants to merge 2 commits into
Open
fix: use entity field names in CLI delete select instead of PK constraint names#1329pyramation wants to merge 2 commits into
pyramation wants to merge 2 commits into
Conversation
…aint names The codegen for CLI delete handlers was using PK constraint field names (e.g. principalId) in the select clause, but these names come from PostGraphile's inflected mutation input names and may differ from the entity's actual field names (e.g. id) in the Select type. Use buildSelectObject() for delete (same as create/update) to ensure select uses entity field names that match the generated Select types.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…g all fields Map PK constraint names back to entity field names via reverse inflection (e.g. principalId → id) so delete select stays minimal while using correct field names that exist on the generated *Select type.
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.
Summary
The CLI codegen for
handleDeletewas building theselectclause from PK constraint field names (viagetPrimaryKeyInfo()), which use PostGraphile's inflected mutation input names. For tables where the inflected PK name differs from the entity field name (e.g.principaltable: constraint PK =principalId, entity field =id), the generatedselect: { principalId: true }fails TypeScript compilation becauseprincipalIddoesn't exist onPrincipalSelect.Delete select stays minimal (just the PK field) but now resolves the correct entity field name via reverse inflection.
Also fixed the already-generated
sdk/constructive-cli/src/auth/cli/commands/principal.tsto unblock CI immediately.Link to Devin session: https://app.devin.ai/sessions/713a7eeac5ee47abae2dc5a13a23e067
Requested by: @pyramation