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
[P0][bug] compareSchemas normalizes DDL via whitespace+lowercase — string-literal changes are reported identical #371
Schema Compare & Sync treats views/routines/triggers DDL as opaque strings.
Problem
src/lib/schema-diff.ts:163-186 uses normalizeDdl = ddl => ddl.replace(/\s+/g, ' ').trim().toLowerCase(). The lowercase collapses string literals, so two views that differ only in a string literal inside the SELECT are reported identical. Concrete: CREATE VIEW v AS SELECT * FROM users WHERE name = 'Alice' and ... name = 'alice' lowercased to the same 'alice' — reported identical even though the row sets differ. Same trap for default values, comments, function bodies. Table columns are compared field-by-field and don't have the bug; views/routines/triggers do. The sync generator would emit CREATE OR REPLACE VIEW v AS <source-ddl> on a re-compare, but the diff UI shows the views as identical — no user signal that a sync is needed.
Files
src/lib/schema-diff.ts:11 (normalizeDdl)
src/lib/schema-diff.ts:163-186 (callers)
Repro
Create two views: v1 SELECT * FROM users WHERE name = 'Alice' and v2 SELECT * FROM users WHERE name = 'bob'
Schema Compare source/target
Both views report as "identical" — wait, the second example SHOULD differ ("Alice" vs "bob"). Use Alice vs alice to confirm the bug.
Expected
Two views that differ inside a string literal are reported as "different".
Proposed fix
Replace normalizeDdl with a tokenizer that normalises structural tokens (keywords, identifiers, operators, whitespace) while preserving string-literal contents verbatim. Or compute a server-side checksum: MD5(SHOW CREATE VIEW v) for views, MD5(SHOW CREATE PROCEDURE p) for routines (MySQL allows SHOW CREATE on these). Pass hashes from snapshot fetch and compare by hash. Add unit tests covering the false-positive cases. Scope: M.
Acceptance
Two views that differ only inside a string literal in the SELECT list are reported as "different". Two views that differ only in formatting (whitespace, keyword case) are reported as identical.
Schema compare could not back the claim it made — foreign keys were absent from the snapshot entirely, DDL was compared after lowercasing and collapsing whitespace, and column order was ignored — while the sync half could leave a target half-migrated. A compare tool that is quietly wrong is worse than none, because people act on its answer.
Fixing that properly is a real piece of work, most of it a genuine DDL comparison rather than string normalisation, and the feature is not part of how this project is used. Removed rather than carried: the history has it if someone wants it back.
Removed in the PR closing this issue: SchemaCompare, SyncPreview, schema-diff, sync-sql-generator, their tests, the compare editor tab type, and the menu, title-bar and toolbar entry points.
Activity
EVWorth commentedon Sep 9, 2026
Closed by removing the feature.
Schema compare could not back the claim it made — foreign keys were absent from the snapshot entirely, DDL was compared after lowercasing and collapsing whitespace, and column order was ignored — while the sync half could leave a target half-migrated. A compare tool that is quietly wrong is worse than none, because people act on its answer.
Fixing that properly is a real piece of work, most of it a genuine DDL comparison rather than string normalisation, and the feature is not part of how this project is used. Removed rather than carried: the history has it if someone wants it back.
Removed in the PR closing this issue: SchemaCompare, SyncPreview, schema-diff, sync-sql-generator, their tests, the
compareeditor tab type, and the menu, title-bar and toolbar entry points.feat: remove schema compare (#577)