Fix tests

This commit is contained in:
Adria Navarro 2024-12-19 14:42:49 +01:00
parent 7cc03b1724
commit 16fb86549b
2 changed files with 25 additions and 29 deletions

View File

@ -200,8 +200,8 @@ export async function buildSqlFieldList(
if (
isView &&
source.schema?.[field.name] &&
!helpers.views.isVisible(source.schema[field.name]) &&
(!source.schema?.[field.name] ||
!helpers.views.isVisible(source.schema[field.name])) &&
!containsFormula
) {
continue

View File

@ -362,33 +362,6 @@ describe("buildSqlFieldList", () => {
expect(result).toEqual(["table.amount"])
})
it("includes relationships fields when flagged", async () => {
const otherTable = new TableConfig("linkedTable")
.withField("id", FieldType.NUMBER)
.withPrimary("id")
.withDisplay("name")
.create()
const table = new TableConfig("table")
.withRelation("link", otherTable._id)
.withField("formula", FieldType.FORMULA)
.create()
const view = new ViewConfig(table)
.withVisible("name")
.withHidden("amount")
.create()
const result = await buildSqlFieldList(view, allTables, {
relationships: true,
})
expect(result).toEqual([
"table.name",
"linkedTable.id",
"linkedTable.name",
])
})
it("includes relationships columns", async () => {
const otherTable = new TableConfig("linkedTable")
.withField("id", FieldType.NUMBER)
@ -420,6 +393,29 @@ describe("buildSqlFieldList", () => {
])
})
it("excludes relationships fields when view is not included in the view", async () => {
const otherTable = new TableConfig("linkedTable")
.withField("id", FieldType.NUMBER)
.withPrimary("id")
.withDisplay("name")
.create()
const table = new TableConfig("table")
.withRelation("link", otherTable._id)
.withField("formula", FieldType.FORMULA)
.create()
const view = new ViewConfig(table)
.withVisible("name")
.withHidden("amount")
.create()
const result = await buildSqlFieldList(view, allTables, {
relationships: true,
})
expect(result).toEqual(["table.name"])
})
it("does not include relationships columns for hidden links", async () => {
const otherTable = new TableConfig("linkedTable")
.withField("id", FieldType.NUMBER)