Fix tests
This commit is contained in:
parent
7cc03b1724
commit
16fb86549b
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue