handle sparse, zerofill, unsigned, commant flags

This commit is contained in:
Jan Prochazka
2022-02-10 13:32:38 +01:00
parent 691bb0af4f
commit 0debe66dd0
11 changed files with 81 additions and 5 deletions

View File

@@ -15,7 +15,9 @@ function getColumnInfo({
numericScale,
defaultValue,
columnComment,
columnType,
}) {
const columnTypeTokens = _.isString(columnType) ? columnType.split(' ').map(x => x.trim().toLowerCase()) : [];
let fullDataType = dataType;
if (charMaxLength && isTypeString(dataType)) fullDataType = `${dataType}(${charMaxLength})`;
if (numericPrecision && numericScale && isTypeNumeric(dataType))
@@ -27,6 +29,8 @@ function getColumnInfo({
columnComment,
dataType: fullDataType,
defaultValue,
isUnsigned: columnTypeTokens.includes('unsigned'),
isZerofill: columnTypeTokens.includes('zerofill'),
};
}

View File

@@ -9,6 +9,7 @@ select
NUMERIC_SCALE as numericScale,
COLUMN_DEFAULT as defaultValue,
COLUMN_COMMENT as columnComment,
COLUMN_TYPE as columnType,
EXTRA as extra
from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = '#DATABASE#' and TABLE_NAME =OBJECT_ID_CONDITION

View File

@@ -38,6 +38,22 @@ class Dumper extends SqlDumper {
this.endCommand();
}
specialColumnOptions(column) {
if (column.isUnsigned) {
this.put('^unsigned ');
}
if (column.isZerofill) {
this.put('^zerofill ');
}
}
columnDefinition(col, options) {
super.columnDefinition(col, options);
if (col.columnComment) {
this.put(' ^comment %v ', col.columnComment);
}
}
renameColumn(column, newcol) {
this.changeColumn(
column,

View File

@@ -33,6 +33,8 @@ const dialect = {
columnProperties: {
columnComment: true,
isUnsigned: true,
isZerofill: true,
},
};