Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix][Connector] Fix jdbc compile error #7359

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ protected Column buildColumn(ResultSet resultSet) throws SQLException {
}

@Override
protected String getCreateTableSql(TablePath tablePath, CatalogTable table) {
return OceanBaseMysqlCreateTableSqlBuilder.builder(tablePath, table, typeConverter)
protected String getCreateTableSql(
TablePath tablePath, CatalogTable table, boolean createIndex) {
return OceanBaseMysqlCreateTableSqlBuilder.builder(
tablePath, table, typeConverter, createIndex)
.build(table.getCatalogName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,29 @@ public class OceanBaseMysqlCreateTableSqlBuilder {
private String fieldIde;

private final OceanBaseMySqlTypeConverter typeConverter;
private boolean createIndex;

private OceanBaseMysqlCreateTableSqlBuilder(
String tableName, OceanBaseMySqlTypeConverter typeConverter) {
String tableName, OceanBaseMySqlTypeConverter typeConverter, boolean createIndex) {
checkNotNull(tableName, "tableName must not be null");
this.tableName = tableName;
this.typeConverter = typeConverter;
this.createIndex = createIndex;
}

public static OceanBaseMysqlCreateTableSqlBuilder builder(
TablePath tablePath,
CatalogTable catalogTable,
OceanBaseMySqlTypeConverter typeConverter) {
OceanBaseMySqlTypeConverter typeConverter,
boolean createIndex) {
checkNotNull(tablePath, "tablePath must not be null");
checkNotNull(catalogTable, "catalogTable must not be null");

TableSchema tableSchema = catalogTable.getTableSchema();
checkNotNull(tableSchema, "tableSchema must not be null");

return new OceanBaseMysqlCreateTableSqlBuilder(tablePath.getTableName(), typeConverter)
return new OceanBaseMysqlCreateTableSqlBuilder(
tablePath.getTableName(), typeConverter, createIndex)
.comment(catalogTable.getComment())
// todo: set charset and collate
.engine(null)
Expand Down Expand Up @@ -158,10 +162,10 @@ private String buildColumnsIdentifySql(String catalogName) {
for (Column column : columns) {
columnSqls.add("\t" + buildColumnIdentifySql(column, catalogName, columnTypeMap));
}
if (primaryKey != null) {
if (createIndex && primaryKey != null) {
columnSqls.add("\t" + buildPrimaryKeySql());
}
if (CollectionUtils.isNotEmpty(constraintKeys)) {
if (createIndex && CollectionUtils.isNotEmpty(constraintKeys)) {
for (ConstraintKey constraintKey : constraintKeys) {
if (StringUtils.isBlank(constraintKey.getConstraintName())) {
continue;
Expand Down
Loading