This commit is contained in:
Sam Rose 2024-11-21 17:33:47 +00:00
parent f02797416a
commit ebf82a0ef5
No known key found for this signature in database
2 changed files with 57 additions and 0 deletions

View File

@ -3495,6 +3495,59 @@ if (descriptions.length) {
)
})
})
!isInternal &&
describe("bigint ids", () => {
let table: Table
let relatedTable: Table
beforeAll(async () => {
const tableName = generator.guid().substring(0, 10)
await client!.schema.createTable(tableName, table => {
table.bigIncrements("id").primary()
})
const relatedTableName = generator.guid().substring(0, 10)
await client!.schema.createTable(relatedTableName, table => {
table.increments("id").primary()
table
.bigInteger("tableid")
.unsigned()
.references("id")
.inTable(tableName)
})
const resp = await config.api.datasource.fetchSchema({
datasourceId: datasource!._id!,
})
const tables = Object.values(resp.datasource.entities || {})
table = tables.find(t => t.name === tableName)!
relatedTable = tables.find(t => t.name === relatedTableName)!
await config.api.table.save({
...table,
schema: {
...table.schema,
related: {
name: "related",
type: FieldType.LINK,
tableId: relatedTable._id!,
fieldName: "tableid",
relationshipType: RelationshipType.ONE_TO_MANY,
},
},
})
})
it.only("should be able to fetch rows with related bigint ids", async () => {
const row = await config.api.row.save(table._id!, {})
await config.api.row.save(relatedTable._id!, { tableid: row.id })
const { rows } = await config.api.row.search(table._id!)
expect(rows).toEqual([])
})
})
}
)
}

View File

@ -39,6 +39,10 @@ if (types) {
types.setTypeParser(1114, (val: any) => val) // timestamp
types.setTypeParser(1082, (val: any) => val) // date
types.setTypeParser(1184, (val: any) => val) // timestampz
// types.setTypeParser(114, JSON.parse) // json
// types.setTypeParser(3802, JSON.parse) // jsonb
// types.setTypeParser(199, parseJsonArray) // json[]
// types.setTypeParser(3807, parseJsonArray) // jsonb[]
}
const JSON_REGEX = /'{\s*.*?\s*}'::json/gs