Only treat tinyint(1) and tinyint(0) as booleans (#7287)

* added an if catch for tinyint(1) and tinyint(0)

* made suggested changes toLowerCase()
This commit is contained in:
Jay Cammarano
2021-08-09 15:36:24 -04:00
committed by GitHub
parent e1c6bc5ac9
commit d8889d777e

View File

@@ -6,7 +6,7 @@ import getDatabase from '../database';
const localTypeMap: Record<string, { type: Type; useTimezone?: boolean }> = {
// Shared
boolean: { type: 'boolean' },
tinyint: { type: 'boolean' },
tinyint: { type: 'integer' },
smallint: { type: 'integer' },
mediumint: { type: 'integer' },
int: { type: 'integer' },
@@ -117,7 +117,6 @@ export default function getLocalType(
}
}
}
/** Handle Postgres numeric decimals */
if (column.data_type === 'numeric' && column.numeric_precision !== null && column.numeric_scale !== null) {
return 'decimal';
@@ -128,6 +127,11 @@ export default function getLocalType(
return 'text';
}
/** Handle Boolean as TINYINT*/
if (column.data_type.toLowerCase() === 'tinyint(1)' || column.data_type.toLowerCase() === 'tinyint(0)') {
return 'boolean';
}
if (type) {
return type.type;
}