Hotfix v0.3.2: Inline edit silently failing on non-id primary keys (#44)#54
Merged
Conversation
handleUpdate and handleBooleanToggle in EditableCellRelational.vue
detected the primary key by name pattern matching
(key === 'id' || key.endsWith('_id')), which produced no result on
collections whose primary key uses a different name (code, slug, uuid,
sku, ...). The emit was skipped silently and the inline edit never
reached the database.
Both handlers now read the primary key field name from the
primaryKeyField computed property, which the parent component sources
from the Directus schema via useCollection. This also closes a latent
risk: when an item carried both the real primary key and an unrelated
field named id or ending in _id, the previous heuristic could pick the
wrong column and dispatch the PATCH against an unrelated record.
Quality Check ResultsTypeScript Type Check✅ Passed - No type errors found ESLint✅ Passed - No linting errors Prettier Format Check✅ Passed - Code is properly formatted Build✅ Passed - Extension builds successfully Updated: 2026-05-09T17:07:49.525Z |
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
Closes #44.
handleUpdateandhandleBooleanToggleinEditableCellRelational.vuedetected the primary key by name-pattern matching:When the primary key has a different name (
code,slug,uuid,sku, …), the lookup returnsundefined, theif-guard short-circuits, no event is emitted, and the inline edit silently never reaches the database — exactly the behaviour reported in #44.The fix uses the
primaryKeyFieldcomputed property that already exists in the same component. Its value is sourced fromuseCollection().primaryKeyFieldin the parent (super-table.vue) and passed in asprimary-key-field-name, so it is always the schema-authoritative PK field name.Why the same pattern was a latent data-corruption risk
When an item carries both a real primary key (e.g.
code = "PROD-A1") and an unrelated field literally namedid(or ending in_idlikeparent_id), the previous heuristic preferred those over the actual PK. The PATCH would then be dispatched against\/items\/<collection>\/<id_value>instead of\/items\/<collection>\/<pk_value>— at best a 404, at worst an update to an unrelated record. The new code reads the schema-authoritative PK name, so this misdirection is no longer possible.Verification
Reproduced the original bug, applied the fix, and re-tested manually against the running Directus instance:
codePK + inline string editPATCH /items/test_bug_44/ITEM-001→ 200, DB updatedcodePK + direct boolean togglePATCH /items/test_bug_44/ITEM-002→ 200, DB updatedidPK (regression)PATCH /items/test_bug_44_id/1→ 200, DB updatedskuPK with extraid=999andparent_id=42fieldsPATCH /items/test_bug_44_evil/PROD-A1→ 200, DB updatedQuality checks pass (
pnpm run quality):vue-tsc --noEmiteslint . --max-warnings=0prettier --checkTest plan
id(e.g.code,uuid), switch to Super Table and enable inline editingPATCH /items/<collection>/<pk-value>and the value to persistPATCHflowid-keyed collection, repeat both interactions → expect no regression