Fix unsigned data type reading in MSSQL (#6058)

Fixes #5999
This commit is contained in:
Rijk van Zanten
2021-06-03 23:11:15 -04:00
committed by GitHub
parent f2180b1650
commit fe6101cfd3

View File

@@ -38,11 +38,22 @@ export default class MySQL extends KnexMySQL implements SchemaInspector {
};
}
let dataType = column.data_type.split('(')[0];
/**
* Smooth out a difference between MySQL and MariaDB. MySQL reports the column type as `int
* unsigned`, while MariaDB reports it as `int(11) unsigned`. This would cause the `unsigned` part
* of the type to be dropped in the columnInfo retrieval for MariaDB powered databases.
*/
if (column.data_type.includes('unsigned') && dataType.includes('unsigned') === false) {
dataType += ' unsigned';
}
overview[column.table_name].columns[column.column_name] = {
...column,
default_value: column.extra === 'auto_increment' ? 'AUTO_INCREMENT' : parseDefaultValue(column.default_value),
is_nullable: column.is_nullable === 'YES',
data_type: column.data_type.split('(')[0],
data_type: dataType,
};
}