mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
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:
co-authored by
Ivan Gagarkin
Evgenia
parent
8b0a20cfd7
commit
36dfdc8b33
+18
-1
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user