From cafe0e68c3604ec65db8a7e80d25725fa9c44df9 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 1 Jun 2024 13:08:51 +0200 Subject: [PATCH] fixes --- packages/tools/src/SqlDumper.ts | 21 ++++++++++++------- .../src/frontend/Dumper.js | 9 ++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/packages/tools/src/SqlDumper.ts b/packages/tools/src/SqlDumper.ts index d4de0c39..38161bda 100644 --- a/packages/tools/src/SqlDumper.ts +++ b/packages/tools/src/SqlDumper.ts @@ -199,14 +199,8 @@ export class SqlDumper implements AlterProcessor { selectScopeIdentity(table: TableInfo) {} - columnDefinition(column: ColumnInfo, { includeDefault = true, includeNullable = true, includeCollate = true } = {}) { - if (column.computedExpression) { - this.put('^as %s', column.computedExpression); - if (column.isPersisted) this.put(' ^persisted'); - return; - } - - const type = column.dataType || this.dialect.fallbackDataType; + columnType(dataType: string) { + const type = dataType || this.dialect.fallbackDataType; const typeWithValues = type.match(/([^(]+)(\(.+[^)]\))/); if (typeWithValues?.length) { @@ -217,6 +211,17 @@ export class SqlDumper implements AlterProcessor { this.putRaw(SqlDumper.convertKeywordCase(type)); } + } + + columnDefinition(column: ColumnInfo, { includeDefault = true, includeNullable = true, includeCollate = true } = {}) { + if (column.computedExpression) { + this.put('^as %s', column.computedExpression); + if (column.isPersisted) this.put(' ^persisted'); + return; + } + + this.columnType(column.dataType); + if (column.autoIncrement) { this.autoIncrement(); } diff --git a/plugins/dbgate-plugin-oracle/src/frontend/Dumper.js b/plugins/dbgate-plugin-oracle/src/frontend/Dumper.js index 9c8a2f9f..74b3f0ed 100644 --- a/plugins/dbgate-plugin-oracle/src/frontend/Dumper.js +++ b/plugins/dbgate-plugin-oracle/src/frontend/Dumper.js @@ -15,6 +15,15 @@ class Dumper extends SqlDumper { // oracle uses implicit transactions beginTransaction() {} + columnDefinition(col, options) { + if (col.autoIncrement) { + super.columnType(col.dataType); + this.put(' ^generated ^by ^default ^on ^null ^as ^identity'); + return; + } + super.columnDefinition(col, options); + } + // /** @param type {import('dbgate-types').TransformType} */ // transform(type, dumpExpr) { // switch (type) {