Browse Source

fix: hive sync error (#135)

master
vran 3 years ago
committed by GitHub
parent
commit
7c412c6136
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java

21
plugin/src/main/java/com/databasir/core/meta/repository/impl/jdbc/JdbcColumnMetaRepository.java

@ -52,10 +52,7 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
if (isNullable.trim().equals("")) { if (isNullable.trim().equals("")) {
isNullable = "UNKNOWN"; isNullable = "UNKNOWN";
} }
String isAutoIncrement = columnsResult.getString("IS_AUTOINCREMENT");
if (isAutoIncrement.trim().equals("")) {
isAutoIncrement = "UNKNOWN";
}
if (defaultValue != null && defaultValue.trim().equals("")) { if (defaultValue != null && defaultValue.trim().equals("")) {
defaultValue = "'" + defaultValue + "'"; defaultValue = "'" + defaultValue + "'";
} }
@ -76,7 +73,7 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
.size(columnSize) .size(columnSize)
.decimalDigits(decimalDigits) .decimalDigits(decimalDigits)
.nullable(isNullable) .nullable(isNullable)
.autoIncrement(isAutoIncrement) .autoIncrement(retrieveAutoIncrement(columnsResult))
.comment(columnComment) .comment(columnComment)
.defaultValue(defaultValue) .defaultValue(defaultValue)
.isPrimaryKey(primaryKeyColumns.contains(columnName)) .isPrimaryKey(primaryKeyColumns.contains(columnName))
@ -90,6 +87,20 @@ public class JdbcColumnMetaRepository implements ColumnMetaRepository {
return columnDocs; return columnDocs;
} }
private String retrieveAutoIncrement(ResultSet columnsResult) {
String isAutoIncrement = null;
try {
isAutoIncrement = columnsResult.getString("IS_AUTOINCREMENT");
if (isAutoIncrement.trim().equals("")) {
isAutoIncrement = "UNKNOWN";
}
return isAutoIncrement;
} catch (SQLException e) {
log.warn("warn: ignore auto increment, error: " + e.getMessage());
return "UNKNOWN";
}
}
private List<String> selectPrimaryKeyColumns(DatabaseMetaData meta, private List<String> selectPrimaryKeyColumns(DatabaseMetaData meta,
TableCondition tableCondition) throws SQLException { TableCondition tableCondition) throws SQLException {
ResultSet result = meta.getPrimaryKeys(tableCondition.getDatabaseName(), ResultSet result = meta.getPrimaryKeys(tableCondition.getDatabaseName(),

Loading…
Cancel
Save