diff --git a/packages/tools/src/SqlDumper.ts b/packages/tools/src/SqlDumper.ts index 8ddc9616e..385bf9e15 100644 --- a/packages/tools/src/SqlDumper.ts +++ b/packages/tools/src/SqlDumper.ts @@ -293,6 +293,20 @@ export class SqlDumper { changeViewSchema(obj: ViewInfo, newSchema: string) {} renameView(obj: ViewInfo, newSchema: string) {} + createMatview(obj: ViewInfo) { + this.putRaw(obj.createSql); + this.endCommand(); + } + dropMatview(obj: ViewInfo, { testIfExists = false }) { + this.putCmd('^drop ^materialized ^view %f', obj); + } + alterMatview(obj: ViewInfo) { + this.putRaw(obj.createSql.replace(/create\s+view/i, 'ALTER VIEW')); + this.endCommand(); + } + changeMatviewSchema(obj: ViewInfo, newSchema: string) {} + renameMatview(obj: ViewInfo, newSchema: string) {} + createProcedure(obj: ProcedureInfo) { this.putRaw(obj.createSql); this.endCommand(); diff --git a/packages/tools/src/SqlGenerator.ts b/packages/tools/src/SqlGenerator.ts index 9d7ecfe1c..48b0d103a 100644 --- a/packages/tools/src/SqlGenerator.ts +++ b/packages/tools/src/SqlGenerator.ts @@ -30,6 +30,10 @@ interface SqlGeneratorOptions { checkIfViewExists: boolean; createViews: boolean; + dropMatviews: boolean; + checkIfMatviewExists: boolean; + createMatviews: boolean; + dropProcedures: boolean; checkIfProcedureExists: boolean; createProcedures: boolean; @@ -52,6 +56,7 @@ interface SqlGeneratorObject { export class SqlGenerator { private tables: TableInfo[]; private views: ViewInfo[]; + private matviews: ViewInfo[]; private procedures: ProcedureInfo[]; private functions: FunctionInfo[]; private triggers: TriggerInfo[]; @@ -70,6 +75,7 @@ export class SqlGenerator { this.dbinfo = extendDatabaseInfo(dbinfo); this.tables = this.extract('tables'); this.views = this.extract('views'); + this.matviews = this.extract('matviews'); this.procedures = this.extract('procedures'); this.functions = this.extract('functions'); this.triggers = this.extract('triggers'); @@ -90,6 +96,8 @@ export class SqlGenerator { if (this.checkDumper()) return; this.dropObjects(this.views, 'View'); if (this.checkDumper()) return; + this.dropObjects(this.matviews, 'Matview'); + if (this.checkDumper()) return; this.dropObjects(this.triggers, 'Trigger'); if (this.checkDumper()) return; @@ -114,6 +122,8 @@ export class SqlGenerator { if (this.checkDumper()) return; this.createObjects(this.views, 'View'); if (this.checkDumper()) return; + this.createObjects(this.matviews, 'Matview'); + if (this.checkDumper()) return; this.createObjects(this.triggers, 'Trigger'); if (this.checkDumper()) return; } finally { diff --git a/packages/web/src/impexp/FormTablesSelect.svelte b/packages/web/src/impexp/FormTablesSelect.svelte index 12c3004c9..b8e4c16a7 100644 --- a/packages/web/src/impexp/FormTablesSelect.svelte +++ b/packages/web/src/impexp/FormTablesSelect.svelte @@ -5,6 +5,7 @@ import { getFormContext } from '../forms/FormProviderCore.svelte'; import FormSelectField from '../forms/FormSelectField.svelte'; +import { getObjectTypeFieldLabel } from '../utility/common'; import { useDatabaseInfo, useDatabaseList } from '../utility/metadataLoaders'; export let conidName; @@ -15,19 +16,25 @@ const { values, setFieldValue } = getFormContext(); $: dbinfo = useDatabaseInfo({ conid: $values[conidName], database: $values[databaseName] }); - $: tablesOptions = _.compact([...($dbinfo?.tables || []), ...($dbinfo?.views || []), ...($dbinfo?.collections || [])]) + $: tablesOptions = _.compact([ + ...($dbinfo?.tables || []), + ...($dbinfo?.views || []), + ...($dbinfo?.matviews || []), + ...($dbinfo?.collections || []), + ]) .filter(x => !$values[schemaName] || x.schemaName == $values[schemaName]) .map(x => ({ value: x.pureName, label: x.pureName, })); +