knex-schema-inspector
Advanced tools
Comparing version 1.5.4 to 1.5.5
@@ -53,6 +53,16 @@ "use strict"; | ||
var _a, _b; | ||
var dataType = rawColumn.COLUMN_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 (rawColumn.COLUMN_TYPE.includes('unsigned') && | ||
dataType.includes('unsigned') === false) { | ||
dataType += ' unsigned'; | ||
} | ||
return { | ||
name: rawColumn.COLUMN_NAME, | ||
table: rawColumn.TABLE_NAME, | ||
data_type: rawColumn.COLUMN_TYPE.split('(')[0], | ||
data_type: dataType, | ||
default_value: (_a = parseDefaultValue(rawColumn.COLUMN_DEFAULT)) !== null && _a !== void 0 ? _a : parseDefaultValue(rawColumn.GENERATION_EXPRESSION || null), | ||
@@ -59,0 +69,0 @@ max_length: rawColumn.CHARACTER_MAXIMUM_LENGTH, |
@@ -37,6 +37,20 @@ import { Knex } from 'knex'; | ||
export function rawColumnToColumn(rawColumn: RawColumn): Column { | ||
let dataType = rawColumn.COLUMN_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 ( | ||
rawColumn.COLUMN_TYPE.includes('unsigned') && | ||
dataType.includes('unsigned') === false | ||
) { | ||
dataType += ' unsigned'; | ||
} | ||
return { | ||
name: rawColumn.COLUMN_NAME, | ||
table: rawColumn.TABLE_NAME, | ||
data_type: rawColumn.COLUMN_TYPE.split('(')[0], | ||
data_type: dataType, | ||
default_value: | ||
@@ -43,0 +57,0 @@ parseDefaultValue(rawColumn.COLUMN_DEFAULT) ?? |
{ | ||
"name": "knex-schema-inspector", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "Utility for extracting information about existing DB schema", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
290129
6316