diff --git a/packages/server/src/integrations/mysql.ts b/packages/server/src/integrations/mysql.ts index 1cd9a356b3..31ba7cf207 100644 --- a/packages/server/src/integrations/mysql.ts +++ b/packages/server/src/integrations/mysql.ts @@ -147,7 +147,8 @@ class MySQLIntegration extends Sql implements DatasourcePlus { if ( field.type == "DATETIME" || field.type === "DATE" || - field.type === "TIMESTAMP" + field.type === "TIMESTAMP" || + field.type === "LONGLONG" ) { return field.string() } diff --git a/packages/server/src/integrations/utils.ts b/packages/server/src/integrations/utils.ts index 1861cc9662..4681cd4f2a 100644 --- a/packages/server/src/integrations/utils.ts +++ b/packages/server/src/integrations/utils.ts @@ -8,7 +8,6 @@ const ROW_ID_REGEX = /^\[.*]$/g const SQL_NUMBER_TYPE_MAP = { integer: FieldTypes.NUMBER, int: FieldTypes.NUMBER, - bigint: FieldTypes.NUMBER, decimal: FieldTypes.NUMBER, smallint: FieldTypes.NUMBER, real: FieldTypes.NUMBER, @@ -47,6 +46,7 @@ const SQL_STRING_TYPE_MAP = { blob: FieldTypes.STRING, long: FieldTypes.STRING, text: FieldTypes.STRING, + bigint: FieldTypes.STRING, } const SQL_BOOLEAN_TYPE_MAP = { @@ -141,12 +141,18 @@ export function breakRowIdField(_id: string | { _id: string }): any[] { export function convertSqlType(type: string) { let foundType = FieldTypes.STRING const lcType = type.toLowerCase() + let matchingTypes = [] for (let [external, internal] of Object.entries(SQL_TYPE_MAP)) { if (lcType.includes(external)) { - foundType = internal - break + matchingTypes.push({ external, internal }) } } + //Set the foundType based the longest match + if (matchingTypes.length > 0) { + foundType = matchingTypes.reduce((acc, val) => { + return acc.external.length >= val.external.length ? acc : val + }).internal + } const schema: any = { type: foundType } if (foundType === FieldTypes.DATETIME) { schema.dateOnly = SQL_DATE_ONLY_TYPES.includes(lcType)