Revert "Trying to make it easier to understand my tests."

This reverts commit 93d8bd792c.
This commit is contained in:
Sam Rose 2024-11-25 17:53:11 +00:00
parent 50a7539e25
commit c3b2c2e1c7
No known key found for this signature in database
2 changed files with 26 additions and 24 deletions

View File

@ -1218,8 +1218,10 @@ 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.raw(`?${separator}??`, [unaliased, identifier]).toString() return this.knex
.raw(`?${separator}??`, [unaliased, identifier])
.toString()
} }
maxFunctionParameters() { maxFunctionParameters() {

View File

@ -3498,23 +3498,23 @@ if (descriptions.length) {
if (!isInternal) { if (!isInternal) {
describe("bigint ids", () => { describe("bigint ids", () => {
let table1: Table, table2: Table let table: Table, relatedTable: Table
let table1Name: string, table2Name: string let tableName: string, relatedTableName: string
beforeAll(async () => { beforeAll(async () => {
table1Name = `table1-${generator.guid().substring(0, 5)}` tableName = generator.guid().substring(0, 10)
await client!.schema.createTable(table1Name, table => { await client!.schema.createTable(tableName, table => {
table.bigIncrements("table1Id").primary() table.bigIncrements("id").primary()
}) })
table2Name = `table2-${generator.guid().substring(0, 5)}` relatedTableName = generator.guid().substring(0, 10)
await client!.schema.createTable(table2Name, table => { await client!.schema.createTable(relatedTableName, table => {
table.increments("table2Id").primary() table.increments("id").primary()
table table
.bigInteger("table1Ref") .bigInteger("tableid")
.unsigned() .unsigned()
.references("table1Id") .references("id")
.inTable(table1Name) .inTable(tableName)
}) })
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 || {})
table1 = tables.find(t => t.name === table1Name)! table = tables.find(t => t.name === tableName)!
table2 = tables.find(t => t.name === table2Name)! relatedTable = tables.find(t => t.name === relatedTableName)!
await config.api.datasource.addExistingRelationship({ await config.api.datasource.addExistingRelationship({
one: { one: {
tableId: table2._id!, tableId: relatedTable._id!,
relationshipName: "one", relationshipName: "one",
foreignKey: "table1Ref", foreignKey: "tableid",
}, },
many: { many: {
tableId: table1._id!, tableId: table._id!,
relationshipName: "many", relationshipName: "many",
primaryKey: "table1Id", primaryKey: "id",
}, },
}) })
}) })
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(table1._id!, {}) const row = await config.api.row.save(table._id!, {})
await config.api.row.save(table2._id!, { table1Ref: row.id }) await config.api.row.save(relatedTable._id!, { tableid: row.id })
const { rows } = await config.api.row.search(table1._id!) const { rows } = await config.api.row.search(table._id!)
expect(rows).toEqual([ expect(rows).toEqual([
expect.objectContaining({ expect.objectContaining({
_id: "%5B'1'%5D", _id: "%5B'1'%5D",
_rev: "rev", _rev: "rev",
table1Id: "1", id: "1",
many: [ related: [
{ {
_id: "%5B'1'%5D", _id: "%5B'1'%5D",
primaryDisplay: 1, primaryDisplay: 1,