Trying to make it easier to understand my tests.
This commit is contained in:
parent
98717de61f
commit
93d8bd792c
|
@ -1218,10 +1218,8 @@ class InternalBuilder {
|
||||||
if (otherField.type === FieldType.BIGINT) {
|
if (otherField.type === FieldType.BIGINT) {
|
||||||
identifier = this.castIntToString(identifier)
|
identifier = this.castIntToString(identifier)
|
||||||
}
|
}
|
||||||
} else if (schema.autocolumn && schema.autoReason === "foreign_key")
|
}
|
||||||
return this.knex
|
return this.knex.raw(`?${separator}??`, [unaliased, identifier]).toString()
|
||||||
.raw(`?${separator}??`, [unaliased, identifier])
|
|
||||||
.toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maxFunctionParameters() {
|
maxFunctionParameters() {
|
||||||
|
|
|
@ -3498,23 +3498,23 @@ if (descriptions.length) {
|
||||||
|
|
||||||
if (!isInternal) {
|
if (!isInternal) {
|
||||||
describe("bigint ids", () => {
|
describe("bigint ids", () => {
|
||||||
let table: Table, relatedTable: Table
|
let table1: Table, table2: Table
|
||||||
let tableName: string, relatedTableName: string
|
let table1Name: string, table2Name: string
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
tableName = generator.guid().substring(0, 10)
|
table1Name = `table1-${generator.guid().substring(0, 5)}`
|
||||||
await client!.schema.createTable(tableName, table => {
|
await client!.schema.createTable(table1Name, table => {
|
||||||
table.bigIncrements("id").primary()
|
table.bigIncrements("table1Id").primary()
|
||||||
})
|
})
|
||||||
|
|
||||||
relatedTableName = generator.guid().substring(0, 10)
|
table2Name = `table2-${generator.guid().substring(0, 5)}`
|
||||||
await client!.schema.createTable(relatedTableName, table => {
|
await client!.schema.createTable(table2Name, table => {
|
||||||
table.increments("id").primary()
|
table.increments("table2Id").primary()
|
||||||
table
|
table
|
||||||
.bigInteger("tableid")
|
.bigInteger("table1Ref")
|
||||||
.unsigned()
|
.unsigned()
|
||||||
.references("id")
|
.references("table1Id")
|
||||||
.inTable(tableName)
|
.inTable(table1Name)
|
||||||
})
|
})
|
||||||
|
|
||||||
const resp = await config.api.datasource.fetchSchema({
|
const resp = await config.api.datasource.fetchSchema({
|
||||||
|
@ -3522,34 +3522,34 @@ if (descriptions.length) {
|
||||||
})
|
})
|
||||||
|
|
||||||
const tables = Object.values(resp.datasource.entities || {})
|
const tables = Object.values(resp.datasource.entities || {})
|
||||||
table = tables.find(t => t.name === tableName)!
|
table1 = tables.find(t => t.name === table1Name)!
|
||||||
relatedTable = tables.find(t => t.name === relatedTableName)!
|
table2 = tables.find(t => t.name === table2Name)!
|
||||||
|
|
||||||
await config.api.datasource.addExistingRelationship({
|
await config.api.datasource.addExistingRelationship({
|
||||||
one: {
|
one: {
|
||||||
tableId: relatedTable._id!,
|
tableId: table2._id!,
|
||||||
relationshipName: "one",
|
relationshipName: "one",
|
||||||
foreignKey: "tableid",
|
foreignKey: "table1Ref",
|
||||||
},
|
},
|
||||||
many: {
|
many: {
|
||||||
tableId: table._id!,
|
tableId: table1._id!,
|
||||||
relationshipName: "many",
|
relationshipName: "many",
|
||||||
primaryKey: "id",
|
primaryKey: "table1Id",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.only("should be able to fetch rows with related bigint ids", async () => {
|
it.only("should be able to fetch rows with related bigint ids", async () => {
|
||||||
const row = await config.api.row.save(table._id!, {})
|
const row = await config.api.row.save(table1._id!, {})
|
||||||
await config.api.row.save(relatedTable._id!, { tableid: row.id })
|
await config.api.row.save(table2._id!, { table1Ref: row.id })
|
||||||
|
|
||||||
const { rows } = await config.api.row.search(table._id!)
|
const { rows } = await config.api.row.search(table1._id!)
|
||||||
expect(rows).toEqual([
|
expect(rows).toEqual([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
_id: "%5B'1'%5D",
|
_id: "%5B'1'%5D",
|
||||||
_rev: "rev",
|
_rev: "rev",
|
||||||
id: "1",
|
table1Id: "1",
|
||||||
related: [
|
many: [
|
||||||
{
|
{
|
||||||
_id: "%5B'1'%5D",
|
_id: "%5B'1'%5D",
|
||||||
primaryDisplay: 1,
|
primaryDisplay: 1,
|
||||||
|
|
Loading…
Reference in New Issue