dbeaver/pro#8825 Add tests for translating SQL CREATE/ALTER TABLE sta… (#4237)

* 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 <gagarkin@Ivans-MacBook-Pro.local>
Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
Ivan Gagarkin
2026-03-25 13:51:45 +01:00
committed by GitHub
co-authored by Ivan Gagarkin Evgenia
parent 8b0a20cfd7
commit 36dfdc8b33
@@ -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<SQLDialect, String> 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<SQLDialect, String> 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();
}
}