From 3d3aca3290bf538be2aeeb26d9fc9a90d0f5723d Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Tue, 29 Oct 2024 16:18:57 +0100 Subject: [PATCH] fixed clickhouse default value handling --- plugins/dbgate-plugin-clickhouse/src/backend/Analyser.js | 1 + plugins/dbgate-plugin-clickhouse/src/frontend/Dumper.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/plugins/dbgate-plugin-clickhouse/src/backend/Analyser.js b/plugins/dbgate-plugin-clickhouse/src/backend/Analyser.js index ea34369e..77478449 100644 --- a/plugins/dbgate-plugin-clickhouse/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-clickhouse/src/backend/Analyser.js @@ -45,6 +45,7 @@ class Analyser extends DatabaseAnalyser { .filter((col) => col.pureName == table.pureName) .map((col) => ({ ...col, + defaultValue: col.defaultValue ? col.defaultValue : undefined, ...extractDataType(col.dataType), })), primaryKey: table.primaryKeyColumns diff --git a/plugins/dbgate-plugin-clickhouse/src/frontend/Dumper.js b/plugins/dbgate-plugin-clickhouse/src/frontend/Dumper.js index 0874a583..ada5adb7 100644 --- a/plugins/dbgate-plugin-clickhouse/src/frontend/Dumper.js +++ b/plugins/dbgate-plugin-clickhouse/src/frontend/Dumper.js @@ -13,6 +13,9 @@ class Dumper extends SqlDumper { this.put('^alter ^table %f ^modify ^column %i ', newcol, newcol.columnName); this.columnDefinition(newcol); + if (oldcol.defaultValue != null && newcol.defaultValue == null) { + this.put(' ^remove ^default '); + } this.endCommand(); }