Skip to content

fix(plugins): show a view's own definition in Show DDL and Copy DDL - #3405

Merged
datlechin merged 3 commits into
mainfrom
fix/mssql-view-ddl
Oct 13, 2026
Merged

datlechin merged 3 commits into
mainfrom
fix/mssql-view-ddl

Conversation

@datlechin

Copy link
Copy Markdown
Member

Why

Show DDL on a SQL Server view showed a CREATE TABLE of its columns, with an IDENTITY(1,1) the view never declared. Show DDL, Copy DDL, Structure > DDL and MCP read a view through fetchTableDDL, which only PostgreSQL and MongoDB answered for a view. The others built a fake table or failed.

Change

  • SQL Server, Oracle, Dameng, DuckDB, Redshift and Cassandra show the view's own definition.
  • SQLite, libSQL, D1, SAP HANA, Spanner, Trino and Teradata show it instead of failing.
  • SQL Server: a renamed view shows its current name. Encrypted and unreadable views say why. An indexed view's index is written after a GO line. Edit View's fallback template names the schema.
  • Oracle keeps a view's column names and reports a text over 4000 bytes instead of cutting it. Trino exports read materialized views.

Verified

New tests cover the SQL Server header and batch rules, a real SQLite view through libSQL, and HANA. The SQL Server queries ran against Azure SQL Edge, the Oracle checks against Oracle 23 Free.

Not in this PR

  • The registry drivers reach users with a plugin release.
  • Edit View still opens a plain CREATE VIEW on SQL Server and MySQL, which fails because the view exists.
  • SQL Server table DDL still drops computed columns, identity seeds and composite foreign keys.
  • Oracle lists a materialized view as a table, and its query sits in a LONG column OracleNIO cannot read.

Fixes #3402

fetchTableDDL now answers a view or materialized view with its own CREATE statement on SQL Server, Oracle, Dameng, DuckDB, Redshift, SQLite, libSQL, D1, SAP HANA, Spanner, Trino and Teradata, instead of a CREATE TABLE rebuilt from its columns or an error.
Oracle view DDL names the view's columns, SQL Server escapes ] by code unit and rewrites only the stale part of a view header, and Cassandra answers a materialized view with its own statement.
@datlechin
datlechin merged commit 4fa9068 into main Oct 13, 2026
10 checks passed
@datlechin
datlechin deleted the fix/mssql-view-ddl branch October 13, 2026 12:14
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.

Show DDL generates CREATE TABLE instead of the actual CREATE VIEW definition

1 participant