You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] No type-compatibility check between FK local column and referenced column — invalid FK slips through to save #385
src/components/designer/TableDesigner.tsx:720-790 — the FK editor lets the user pick any local column and any referenced column with no type check. MySQL enforces type compatibility at ALTER TABLE … ADD FOREIGN KEY time — INT REFERENCES VARCHAR(50) raises ERROR 1215 (HY000): Cannot add foreign key constraint. The error surfaces at Save but the user has no pre-flight check. The loadRefTableColumns helper (line 121-132) only fetches column names; types are not loaded.
FK creation with mismatched types shows an inline warning before save. Same-family FK creation succeeds without warning.
Proposed fix
Extend loadRefTableColumns to return Record<string, ColumnInfo[]> (or Record<string, Map<name, type>>) instead of Record<string, string[]>. Compare local column type against referenced column type after normalising: VARCHAR(255) compatible with VARCHAR(50) (same family); INT with BIGINT (target bigger); TEXT with VARCHAR is not. Show an inline warning if mismatched, but allow the user to proceed. Scope: S.
Acceptance
FK creation with mismatched types shows an inline warning before save. Same-family FK creation succeeds without warning.
Activity
fix(designer): show the foreign keys a table already has (#551)