diff --git a/dlink-metadata/dlink-metadata-mysql/src/main/java/com/dlink/metadata/convert/MySqlTypeConvert.java b/dlink-metadata/dlink-metadata-mysql/src/main/java/com/dlink/metadata/convert/MySqlTypeConvert.java index 2020d88381..2b3ef3ec4d 100644 --- a/dlink-metadata/dlink-metadata-mysql/src/main/java/com/dlink/metadata/convert/MySqlTypeConvert.java +++ b/dlink-metadata/dlink-metadata-mysql/src/main/java/com/dlink/metadata/convert/MySqlTypeConvert.java @@ -37,7 +37,8 @@ public ColumnType convert(Column column) { if (Asserts.isNull(column)) { return columnType; } - String t = column.getType().toLowerCase(); + Integer length = Asserts.isNull(column.getLength()) ? 0 : column.getLength(); + String t = Asserts.isNull(column.getType()) ? "" : column.getType().toLowerCase(); boolean isNullable = !column.isKeyFlag() && column.isNullable(); if (t.contains("numeric") || t.contains("decimal")) { columnType = ColumnType.DECIMAL; @@ -59,7 +60,7 @@ public ColumnType convert(Column column) { } else { columnType = ColumnType.DOUBLE; } - } else if (t.contains("boolean") || (t.contains("tinyint") && column.getLength() == 1) || t.contains("bit")) { + } else if (t.contains("boolean") || (t.contains("tinyint") && length.equals(1)) || t.contains("bit")) { if (isNullable) { columnType = ColumnType.JAVA_LANG_BOOLEAN; } else {