From 36dfdc8b33639fb500e29d519126e412f8a3152e Mon Sep 17 00:00:00 2001 From: Ivan Gagarkin Date: Wed, 25 Mar 2026 13:51:45 +0100 Subject: [PATCH] =?UTF-8?q?dbeaver/pro#8825=20Add=20tests=20for=20translat?= =?UTF-8?q?ing=20SQL=20CREATE/ALTER=20TABLE=20sta=E2=80=A6=20(#4237)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * dbeaver/pro#8825 Add tests for translating SQL CREATE/ALTER TABLE statements with ASCII columns * dbeaver/pro#8825 improve script normalization * dbeaver/pro#8825 Update `SQLQueryTranslatorTest` to include `NOT NULL` constraint for ASCII column validation --------- Co-authored-by: Ivan Gagarkin Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com> --- .../test/platform/SQLQueryTranslatorTest.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/test/platform/SQLQueryTranslatorTest.java b/server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/test/platform/SQLQueryTranslatorTest.java index e80f50c0a0..73444e1e11 100644 --- a/server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/test/platform/SQLQueryTranslatorTest.java +++ b/server/test/io.cloudbeaver.test.platform/src/io/cloudbeaver/test/platform/SQLQueryTranslatorTest.java @@ -179,6 +179,20 @@ public class SQLQueryTranslatorTest extends CloudbeaverMockTest { } + @Test + public void createTableWithAscii() throws DBException { + var basicSql = "CREATE TABLE CB_TEST_TYPES (ASCII_COLUMN VARCHAR(128) ASCII NOT NULL);\n"; + + Map expectedSqlByDialect = new HashMap<>(); + expectedSqlByDialect.put(new H2SQLDialect(), "CREATE TABLE CB_TEST_TYPES (ASCII_COLUMN VARCHAR (128) NOT NULL);\n"); + expectedSqlByDialect.put(new PostgreDialect(), "CREATE TABLE CB_TEST_TYPES (ASCII_COLUMN VARCHAR (128) NOT NULL);\n"); + expectedSqlByDialect.put( + new MySQLDialect(), + "CREATE TABLE CB_TEST_TYPES (ASCII_COLUMN VARCHAR (128) CHARACTER SET latin1 NOT NULL);" + ); + translateAndValidateQueries(basicSql, expectedSqlByDialect); + } + private static void translateAndValidateQueries( @NotNull String basicSql, @NotNull Map expectedSqlByDialect @@ -203,7 +217,10 @@ public class SQLQueryTranslatorTest extends CloudbeaverMockTest { private static String normalizeScript(String script) { // Unify for tests - return script.toLowerCase().replace(GeneralUtils.getDefaultLineSeparator(), "\n"); + return script.toLowerCase() + .replaceAll("\\s", " ") + .replace(GeneralUtils.getDefaultLineSeparator(), "\n") + .trim(); } }