Skip to content

fix(schema): keep tables and schemas whose names differ only in Unicode form apart in every reader - #4366

Merged
datlechin merged 10 commits into
mainfrom
fix/schema-reads-unicode-names
Nov 20, 2026
Merged

datlechin merged 10 commits into
mainfrom
fix/schema-reads-unicode-names

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • Tables and schemas whose names differ only in Unicode form (NFC and NFD, which PostgreSQL, SQLite, DuckDB and MariaDB keep apart) were merged by every reader of the schema-wide column, key and index reads: one table showed both tables' columns, keys or indexes, or the other's, and the second table or schema could vanish.
  • PluginKit: new PluginCatalogNameCollision (additive, kit 46, minimum 19). The per-table defaults of fetchAllColumns, fetchAllForeignKeys, fetchAllIndexes and fetchAllTableMetadata throw it when the table list holds two spellings of one name, before reading anything.
  • Drivers: each schema-wide read that groups rows by name (columns, keys, indexes, table metadata) throws it on an answer naming one object in two spellings: PostgreSQL (with PGlite, KingbaseES, CockroachDB, Redshift), SQLite, libSQL, Cloudflare D1, DuckDB, MySQL and MariaDB (with Databend, StarRocks and the SHOW fallback), SQL Server, Oracle, ClickHouse, BigQuery, Snowflake, SAP HANA, Dameng, MongoDB, etcd and Redis. PluginNameSpellings throws the PluginKit type, so the export reads and these share one error. Cassandra, DynamoDB and Spanner allow only ASCII names; Memcached has one table.
  • App: DatabaseDriver.fetchAllColumns, fetchAllForeignKeys, fetchForeignKeys(forTables:) and fetchIndexes(forTables:) answer maps keyed by CatalogName (UTF-8 bytes). PluginDriverAdapter catches only the collision and reads each listed table alone; any other failure is handled as before. Without twins the read is still one read.
  • Readers keyed by bytes: completion's column cache (typed names still match ignoring case), the grid's column catalog and column store key, ER diagram (graph, edges, staged edits, positions, Mermaid and DOT export, VoiceOver), join builder, MCP column search, index and key listings, AI schema context and ranking, compare, the foreign key store, cascade delete preview (SQLite folds ASCII case only), object copy index names, the metadata pool's schema switch and database key, and the sidebar (table and schema lists, row and children caches, the tree and schema catalogs' keys, expansion keys).
  • TableInfo equality and hashing compare names by bytes.
  • Tests changed on purpose: SQLSchemaProviderCatalogTests.caseOnlyNamesAnswerTheirOwnColumns (was caseOnlyNamesAreNotAnswered): "Users" and users each answer their own columns now that the cache keeps them apart. PostgreSQLExportSchemaReadTests.exportColumnReadThrowsOnUnicodeForms and exportForeignKeyReadThrowsOnUnicodeForms now expect the shared reads to throw too. The twin tests that expected PluginNameSpellingError or PostgreSQLCatalogReadError expect PluginCatalogNameCollision.

Test plan

  • New suites fail on main or on the drivers before this change: CatalogNameTests, PluginDriverAdapterTwinReadTests, SQLSchemaProviderTwinTests, ERDiagramTwinTableTests, JoinGraphTwinTests, CompareTwinTableReadTests, CascadeTwinTableTests, AISchemaTwinTableTests, TwinCatalogKeyTests, DatabaseTreeTwinTests, PluginCatalogNameCollisionTests.
  • SQLiteTwinTableCatalogTests opens a real SQLite file through the bundled driver and the app's adapter, ER graph, join graph, MCP index listing and compare: before the driver change one twin held id, b, id, a and both twins' indexes and the other none; after, each twin has its own.
  • PostgreSQL 17.11 (local), the bundled driver through the same app types on a twin fixture: the same merge before, each twin's own columns, keys, indexes and ER node after; two twin schemas each read their own table. A schema without twins sends one statement for columns and one for keys, before and after.
  • Driver suites: SQLiteExportTwinNameTests.sharedReadsThrowOnTwins (new), PostgreSQLExportSchemaReadTests, RedshiftCatalogExportTests, MySQLExportCatalogTests, PluginNameSpellingsTests, ExportUnicodeNameTests.
  • PluginKit ABI against v0.88.0-beta.1: changed, kit 46, minimum 19.

@datlechin
datlechin enabled auto-merge (squash) November 20, 2026 04:14
@datlechin
datlechin disabled auto-merge November 20, 2026 05:33
@datlechin
datlechin merged commit 73b83ac into main Nov 20, 2026
10 checks passed
@datlechin
datlechin deleted the fix/schema-reads-unicode-names branch November 20, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant