Describe the bug
When there are at least two materialized views in a schema, “Script as Create” on the second (and later) views shows the body of the first materialized view, with the later view’s name.
Note: For non-materialized views Script as Create is working correctly.
To Reproduce
-
Run:
CREATE MATERIALIZED VIEW first_matview AS
SELECT 1 AS id, 'first' AS label;
CREATE MATERIALIZED VIEW second_matview AS
SELECT 2 AS id, 'second' AS label;
-
Find second_matview in the connection sidebar, right click it and select "Script as Create". Observe it uses first_matview’s definition, although with the name of second_matview.
Expected behavior
For each materialized view, “Script as Create” should show a CREATE MATERIALIZED VIEW ... AS ... statement whose body matches the definition of that materialized view on the server.
VS Code version
Version: 1.105.1 (user setup)
Commit: 7d842fb85a0275a4a8e4d7e040d2625abbf7f084
Date: 2025-10-14T22:33:36.618Z
Electron: 37.6.0
ElectronBuildId: 12502201
Chromium: 138.0.7204.251
Node.js: 22.19.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200