Unverified Commit a0eb5d76 authored by Lex Li's avatar Lex Li Committed by GitHub

[Fix][metadata-mysql] Bugfix for the numeric column declared by UNSIGNED /…

[Fix][metadata-mysql] Bugfix for the numeric column declared by UNSIGNED / ZEROFILL keyword would cause parsing mismatches (#3371)
parent 7b3f8e27
...@@ -112,10 +112,19 @@ public class MySqlDriver extends AbstractJdbcDriver { ...@@ -112,10 +112,19 @@ public class MySqlDriver extends AbstractJdbcDriver {
? String.format(" DEFAULT '%s'", dv.isEmpty() ? "''" : dv) ? String.format(" DEFAULT '%s'", dv.isEmpty() ? "''" : dv)
: String.format("%s NULL ", !column.isNullable() ? " NOT " : ""); : String.format("%s NULL ", !column.isNullable() ? " NOT " : "");
// Avoid parsing mismatches when the numeric data type column declared by UNSIGNED/ZEROFILL keyword
String columnType = column.getType();
if (columnType.contains("unsigned") || columnType.contains("zerofill")) {
String[] arr = columnType.split(" ");
arr[0] = arr[0].concat(unit);
columnType = String.join(" ", arr);
unit = "";
}
return String.format( return String.format(
" `%s` %s%s%s%s%s", " `%s` %s%s%s%s%s",
column.getName(), column.getName(),
column.getType(), columnType,
unit, unit,
defaultValue, defaultValue,
column.isAutoIncrement() ? " AUTO_INCREMENT " : "", column.isAutoIncrement() ? " AUTO_INCREMENT " : "",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment