Skip to content

fix [BUG] view ddl fail to show for PostgreSQL #1551 #1559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/service/dialect/postgreSqlDialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ ALTER TABLE ${table} ALTER COLUMN ${columnName} ${defaultDefinition};`;
// return `SHOW CREATE TABLE "${database}"."${table}";`
}
showViewSource(database: string, table: string): string {
return `SELECT CONCAT('CREATE VIEW ',table_name,'\nAS\n(',regexp_replace(view_definition,';$',''),')') "Create View",table_name,view_definition from information_schema.views where table_schema='${database}' and table_name='${table}';`
// Use pg_get_viewdef for accurate DDL extraction
return `select pg_get_viewdef('${database}.${table}' :: regclass) "Create View",'${table}' "View";`;
}
showProcedureSource(database: string, name: string): string {
return `select pg_get_functiondef('${database}.${name}' :: regproc) "Create Procedure",'${name}' "Procedure";`;
Expand Down