Skip to content
Open
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 @@ -121,6 +121,7 @@ public class MySQLNoLessThan5700SchemaAccessor implements DBSchemaAccessor {
SPECIAL_TYPE_NAMES.add("bigint");
SPECIAL_TYPE_NAMES.add("float");
SPECIAL_TYPE_NAMES.add("double");
SPECIAL_TYPE_NAMES.add("year");
}

public MySQLNoLessThan5700SchemaAccessor(@NonNull JdbcOperations jdbcOperations) {
Expand Down Expand Up @@ -605,6 +606,13 @@ protected RowMapper<DBTableColumn> listTableRowMapper() {

protected void fillPrecisionAndScale(DBTableColumn column) {
String typeName = column.getTypeName();
/*
In higher mysql version(from 5.7.5),Year's precision is set to default 4 in ddl sql and table construction compare,
especially when columntype=yaer(2),the year's precision will be set 2
*/
if ("year".equalsIgnoreCase(typeName)) {
column.setPrecision(4L);
}
if (SPECIAL_TYPE_NAMES.contains(Objects.isNull(typeName) ? null : typeName.toLowerCase())) {
String precisionAndScale = DBSchemaAccessorUtil.parsePrecisionAndScale(column.getFullTypeName());
if (StringUtils.isBlank(precisionAndScale)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private static void initVerifyDataTypes() {
DataType.of("col24", "time", 0, 0L, 0, null),
DataType.of("col25", "date", 0, null, 0, null),
DataType.of("col26", "datetime", 0, 0L, 0, null),
DataType.of("col27", "year", 0, 0L, 0, null)));
DataType.of("col27", "year", 4, 4L, 0, null)));
}

@Data
Expand Down