What is wrong
CreateTableModal is the only DDL form in the product, and it emits one dialect for every engine.
- The component declares a
dbType prop (src/components/CreateTableModal.tsx), Studio.tsx passes the active connection's type into it, and the component never reads it. The prop is dead.
- The default first column is
id SERIAL PRIMARY KEY, and the type list offers JSONB. Both are PostgreSQL spellings.
- The same text is generated for every engine that publishes
supportsCreateTable: postgres, mysql, mssql, oracle, sqlite, duckdb, libsql, trino. On SQL Server, Oracle and Trino a SERIAL column or a JSONB type does not parse, so pressing Create runs a statement that can only fail.
The modal previews the SQL before the button, so this is visible rather than silent, but the form cannot produce a working auto-increment primary key outside PostgreSQL and MySQL.
Repro
- Connect to SQL Server (or Oracle, or Trino).
- Open the create-table form, keep the default
id column, name the table, press Create.
- The generated
CREATE TABLE t (id SERIAL PRIMARY KEY) fails in the engine.
What it should do
Read dbType and emit that engine's spelling for the two things the form actually offers:
- auto-increment primary key:
GENERATED BY DEFAULT AS IDENTITY (postgres, oracle), IDENTITY(1,1) (mssql), AUTO_INCREMENT (mysql), INTEGER PRIMARY KEY AUTOINCREMENT (sqlite, libsql), a sequence default (duckdb), and no auto-increment offer at all for trino.
- the type list: drop
JSONB where it does not exist and offer the engine's own JSON/text types.
Where an engine cannot express what the checkbox means, the form should not offer the checkbox, the same way supportsCreateTable itself is a published fact rather than a guess. Follow the refusal pattern already used in src/lib/schema-diff/migration-generator.ts, which branches per dialect and returns a reason instead of an invalid statement.
Notes
Reported by a reader on opennet.ru (https://opennet.ru/66216-libredb), who asked how the form reconciles SQL Server's one-checkbox identity with PostgreSQL's sequences. It does not.
Tests are required: tests/components/CreateTableModal.test.tsx exists, and the repo gate is 100% line coverage. One case per engine id asserting the generated SQL is the shape this issue lists.
Help is welcome on this one, and questions in the issue are fine before you start.
What is wrong
CreateTableModalis the only DDL form in the product, and it emits one dialect for every engine.dbTypeprop (src/components/CreateTableModal.tsx),Studio.tsxpasses the active connection's type into it, and the component never reads it. The prop is dead.id SERIAL PRIMARY KEY, and the type list offersJSONB. Both are PostgreSQL spellings.supportsCreateTable:postgres,mysql,mssql,oracle,sqlite,duckdb,libsql,trino. On SQL Server, Oracle and Trino aSERIALcolumn or aJSONBtype does not parse, so pressing Create runs a statement that can only fail.The modal previews the SQL before the button, so this is visible rather than silent, but the form cannot produce a working auto-increment primary key outside PostgreSQL and MySQL.
Repro
idcolumn, name the table, press Create.CREATE TABLE t (id SERIAL PRIMARY KEY)fails in the engine.What it should do
Read
dbTypeand emit that engine's spelling for the two things the form actually offers:GENERATED BY DEFAULT AS IDENTITY(postgres, oracle),IDENTITY(1,1)(mssql),AUTO_INCREMENT(mysql),INTEGER PRIMARY KEY AUTOINCREMENT(sqlite, libsql), a sequence default (duckdb), and no auto-increment offer at all for trino.JSONBwhere it does not exist and offer the engine's own JSON/text types.Where an engine cannot express what the checkbox means, the form should not offer the checkbox, the same way
supportsCreateTableitself is a published fact rather than a guess. Follow the refusal pattern already used insrc/lib/schema-diff/migration-generator.ts, which branches per dialect and returns a reason instead of an invalid statement.Notes
Reported by a reader on opennet.ru (https://opennet.ru/66216-libredb), who asked how the form reconciles SQL Server's one-checkbox identity with PostgreSQL's sequences. It does not.
Tests are required:
tests/components/CreateTableModal.test.tsxexists, and the repo gate is 100% line coverage. One case per engine id asserting the generated SQL is the shape this issue lists.Help is welcome on this one, and questions in the issue are fine before you start.