Treat bigint as string (#8877)

* Make bigint string type

* Handle BigInt relationships

* remove unused var

* Revert CreateEditRelationship modal changes
This commit is contained in:
melohagan 2023-01-22 19:19:16 +00:00 committed by GitHub
parent 403d7eb164
commit 19696fb1fe
2 changed files with 11 additions and 4 deletions

View File

@ -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()
}

View File

@ -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)