Fixes for postgres test case, there was an issue with creating tables with relationships during the creation phase.

This commit is contained in:
mike12345567 2023-11-30 15:09:01 +00:00
parent 160fbf2125
commit 02fefa5529
3 changed files with 25 additions and 3 deletions

View File

@ -527,12 +527,14 @@ describe.each([
otherTableConfig.name = "a"
otherTableConfig.schema.relationship = {
name: "relationship",
type: FieldType.LINK,
fieldName: "relationship",
tableId: table._id!,
relationshipType: RelationshipType.ONE_TO_MANY,
type: FieldType.LINK,
tableId: table._id!,
fieldName: "relationship",
}
otherTable = await createTable(otherTableConfig)
// need to set the config back to the original table
config.table = table
})
it("should update only the fields that are supplied", async () => {

View File

@ -934,25 +934,43 @@ describe("postgres integrations", () => {
},
],
})
const m2oRel = {
[m2oFieldName]: [
{
_id: row._id,
},
],
}
expect(res.body[m2oFieldName]).toEqual([
{
...m2oRel,
...foreignRowsByType[RelationshipType.MANY_TO_ONE][0].row,
[`fk_${manyToOneRelationshipInfo.table.name}_${manyToOneRelationshipInfo.fieldName}`]:
row.id,
},
{
...m2oRel,
...foreignRowsByType[RelationshipType.MANY_TO_ONE][1].row,
[`fk_${manyToOneRelationshipInfo.table.name}_${manyToOneRelationshipInfo.fieldName}`]:
row.id,
},
{
...m2oRel,
...foreignRowsByType[RelationshipType.MANY_TO_ONE][2].row,
[`fk_${manyToOneRelationshipInfo.table.name}_${manyToOneRelationshipInfo.fieldName}`]:
row.id,
},
])
const o2mRel = {
[o2mFieldName]: [
{
_id: row._id,
},
],
}
expect(res.body[o2mFieldName]).toEqual([
{
...o2mRel,
...foreignRowsByType[RelationshipType.ONE_TO_MANY][0].row,
_id: expect.any(String),
_rev: expect.any(String),

View File

@ -136,6 +136,8 @@ export async function save(
schema.main = true
}
// add in the new table for relationship purposes
tables[tableToSave.name] = tableToSave
cleanupRelationships(tableToSave, tables, oldTable)
const operation = tableId ? Operation.UPDATE_TABLE : Operation.CREATE_TABLE