Skip to content

Commit

Permalink
Fix default collation of tables when creating in JDBC DBs, make them …
Browse files Browse the repository at this point in the history
…be consistent with others. (#336)
  • Loading branch information
thongdk8 authored and brfrn169 committed Nov 1, 2021
1 parent a012a52 commit 5962e23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class JdbcDatabaseAdmin implements DistributedStorageAdmin {
ImmutableMap.<DataType, String>builder()
.put(DataType.INT, "INT")
.put(DataType.BIGINT, "BIGINT")
.put(DataType.TEXT, "VARCHAR(8000)")
.put(DataType.TEXT, "VARCHAR(8000) COLLATE Latin1_General_BIN")
.put(DataType.FLOAT, "FLOAT(24)")
.put(DataType.DOUBLE, "FLOAT")
.put(DataType.BOOLEAN, "BIT")
Expand Down Expand Up @@ -154,6 +154,9 @@ public void createNamespace(String namespace, Map<String, String> options)
if (rdbEngine == RdbEngine.ORACLE) {
execute(connection, "CREATE USER " + fullNamespace + " IDENTIFIED BY \"oracle\"");
execute(connection, "ALTER USER " + fullNamespace + " quota unlimited on USERS");
} else if (rdbEngine == RdbEngine.MYSQL) {
execute(
connection, "CREATE SCHEMA " + fullNamespace + " character set utf8 COLLATE utf8_bin");
} else {
execute(connection, "CREATE SCHEMA " + fullNamespace);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public ResultSet mockResultSet(List<GetColumnsResultSetMocker.Row> rows) throws
public void createNamespace_forMysql_shouldExecuteCreateNamespaceStatement()
throws ExecutionException, SQLException {
createNamespace_forX_shouldExecuteCreateNamespaceStatement(
RdbEngine.MYSQL, "CREATE SCHEMA `my_ns`");
RdbEngine.MYSQL, "CREATE SCHEMA `my_ns` character set utf8 COLLATE utf8_bin");
}

@Test
Expand Down Expand Up @@ -216,7 +216,8 @@ public void createTable_forSqlServer_shouldExecuteCreateTableStatement()
throws ExecutionException, SQLException {
createTable_forX_shouldExecuteCreateTableStatement(
RdbEngine.SQL_SERVER,
"CREATE TABLE [my_ns].[foo_table]([c3] BIT,[c1] VARCHAR(8000),[c4] VARBINARY(8000),[c2] BIGINT,[c5] INT,[c6] FLOAT,[c7] FLOAT(24), PRIMARY KEY ([c3],[c1],[c4]))",
"CREATE TABLE [my_ns].[foo_table]([c3] BIT,[c1] VARCHAR(8000) COLLATE Latin1_General_BIN,"
+ "[c4] VARBINARY(8000),[c2] BIGINT,[c5] INT,[c6] FLOAT,[c7] FLOAT(24), PRIMARY KEY ([c3],[c1],[c4]))",
"CREATE INDEX index_my_ns_foo_table_c4 ON [my_ns].[foo_table] ([c4])",
"CREATE INDEX index_my_ns_foo_table_c1 ON [my_ns].[foo_table] ([c1])",
"CREATE SCHEMA [scalardb]",
Expand Down

0 comments on commit 5962e23

Please sign in to comment.