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

[Improve][Connector-V2][Jdbc] Remove MysqlType references in JdbcDialect #7333

Merged
merged 1 commit into from
Aug 7, 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 @@ -40,8 +40,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mysql.cj.MysqlType;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
Expand Down Expand Up @@ -532,8 +530,7 @@ default String buildAlterTableSql(
"ALTER TABLE %s drop column %s", tableName, quoteIdentifier(oldColumnName));
}
TypeConverter<?> typeConverter = ConverterLoader.loadTypeConverter(dialectName());
BasicTypeDefine<MysqlType> typeBasicTypeDefine =
(BasicTypeDefine<MysqlType>) typeConverter.reconvert(newColumn);
BasicTypeDefine typeBasicTypeDefine = (BasicTypeDefine) typeConverter.reconvert(newColumn);

String basicSql = buildAlterTableBasicSql(alterOperation, tableName);
basicSql =
Expand Down Expand Up @@ -616,8 +613,7 @@ default String decorateWithColumnNameAndType(
* @param typeBasicTypeDefine type basic type define of new column
* @return alter table sql with nullable for sink table
*/
default String decorateWithNullable(
String basicSql, BasicTypeDefine<MysqlType> typeBasicTypeDefine) {
default String decorateWithNullable(String basicSql, BasicTypeDefine typeBasicTypeDefine) {
StringBuilder sql = new StringBuilder(basicSql);
if (typeBasicTypeDefine.isNullable()) {
sql.append("NULL ");
Expand All @@ -634,8 +630,7 @@ default String decorateWithNullable(
* @param typeBasicTypeDefine type basic type define of new column
* @return alter table sql with default value for sink table
*/
default String decorateWithDefaultValue(
String basicSql, BasicTypeDefine<MysqlType> typeBasicTypeDefine) {
default String decorateWithDefaultValue(String basicSql, BasicTypeDefine typeBasicTypeDefine) {
Object defaultValue = typeBasicTypeDefine.getDefaultValue();
if (Objects.nonNull(defaultValue)
&& needsQuotesWithDefaultValue(typeBasicTypeDefine.getColumnType())
Expand All @@ -656,8 +651,7 @@ && needsQuotesWithDefaultValue(typeBasicTypeDefine.getColumnType())
* @param typeBasicTypeDefine type basic type define of new column
* @return alter table sql with comment for sink table
*/
default String decorateWithComment(
String basicSql, BasicTypeDefine<MysqlType> typeBasicTypeDefine) {
default String decorateWithComment(String basicSql, BasicTypeDefine typeBasicTypeDefine) {
String comment = typeBasicTypeDefine.getComment();
StringBuilder sql = new StringBuilder(basicSql);
if (StringUtils.isNotBlank(comment)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,12 @@ public void refreshTableSchemaBySchemaChangeEvent(
}

@Override
public String decorateWithComment(
String basicSql, BasicTypeDefine<MysqlType> mysqlTypeBasicTypeDefine) {
MysqlType nativeType = mysqlTypeBasicTypeDefine.getNativeType();
public String decorateWithComment(String basicSql, BasicTypeDefine typeBasicTypeDefine) {
MysqlType nativeType = (MysqlType) typeBasicTypeDefine.getNativeType();
if (NOT_SUPPORTED_DEFAULT_VALUES.contains(nativeType)) {
return basicSql;
}
return JdbcDialect.super.decorateWithComment(basicSql, mysqlTypeBasicTypeDefine);
return JdbcDialect.super.decorateWithComment(basicSql, typeBasicTypeDefine);
}

@Override
Expand Down
Loading