From fdecef7e7895afa626be631f1413cd6390b4d147 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 4 Sep 2022 10:04:24 +0200 Subject: [PATCH] analyse computed columns on ms sql #354 --- .../dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js b/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js index bec92558..76f0f91d 100644 --- a/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js +++ b/plugins/dbgate-plugin-mssql/src/backend/MsSqlAnalyser.js @@ -24,6 +24,15 @@ function objectTypeToField(type) { } } +function simplifyComutedExpression(expr) { + if (expr) { + while (expr.startsWith('(') && expr.endsWith(')')) { + expr = expr.slice(1, -1); + } + } + return expr; +} + function getColumnInfo({ isNullable, isIdentity, @@ -34,6 +43,7 @@ function getColumnInfo({ numericScale, defaultValue, defaultConstraint, + computedExpression, }) { let fullDataType = dataType; if (charMaxLength && isTypeString(dataType)) { @@ -49,6 +59,7 @@ function getColumnInfo({ autoIncrement: !!isIdentity, defaultValue, defaultConstraint, + computedExpression: simplifyComutedExpression(computedExpression), }; }