Only check visible fields when checking group by view calculations.
This commit is contained in:
parent
a47b0d9d62
commit
55be64b371
|
@ -133,9 +133,7 @@ export async function buildSqlFieldList(
|
|||
|
||||
let fields: string[] = []
|
||||
if (sdk.views.isView(source)) {
|
||||
fields = Object.keys(helpers.views.basicFields(source)).filter(
|
||||
key => source.schema?.[key]?.visible !== false
|
||||
)
|
||||
fields = Object.keys(helpers.views.basicFields(source))
|
||||
} else {
|
||||
fields = extractRealFields(source)
|
||||
}
|
||||
|
|
|
@ -800,6 +800,34 @@ describe.each([
|
|||
)
|
||||
}
|
||||
})
|
||||
|
||||
isInternal &&
|
||||
it("shouldn't trigger a complex type check on a group by field if field is invisible", async () => {
|
||||
const table = await config.api.table.save(
|
||||
saveTableRequest({
|
||||
schema: {
|
||||
field: {
|
||||
name: "field",
|
||||
type: FieldType.JSON,
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
await config.api.viewV2.create(
|
||||
{
|
||||
tableId: table._id!,
|
||||
name: generator.guid(),
|
||||
type: ViewV2Type.CALCULATION,
|
||||
schema: {
|
||||
field: { visible: false },
|
||||
},
|
||||
},
|
||||
{
|
||||
status: 201,
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("update", () => {
|
||||
|
|
|
@ -68,9 +68,7 @@ async function buildInternalFieldList(
|
|||
const { relationships, allowedFields } = opts || {}
|
||||
let schemaFields: string[] = []
|
||||
if (sdk.views.isView(source)) {
|
||||
schemaFields = Object.keys(helpers.views.basicFields(source)).filter(
|
||||
key => source.schema?.[key]?.visible !== false
|
||||
)
|
||||
schemaFields = Object.keys(helpers.views.basicFields(source))
|
||||
} else {
|
||||
schemaFields = Object.keys(source.schema).filter(
|
||||
key => source.schema[key].visible !== false
|
||||
|
|
|
@ -33,6 +33,13 @@ export function calculationFields(view: UnsavedViewV2) {
|
|||
return pickBy(view.schema || {}, isCalculationField)
|
||||
}
|
||||
|
||||
export function basicFields(view: UnsavedViewV2) {
|
||||
return pickBy(view.schema || {}, field => !isCalculationField(field))
|
||||
export function isVisible(field: ViewFieldMetadata) {
|
||||
return field.visible !== false
|
||||
}
|
||||
|
||||
export function basicFields(view: UnsavedViewV2, opts?: { visible?: boolean }) {
|
||||
const { visible = true } = opts || {}
|
||||
return pickBy(view.schema || {}, field => {
|
||||
return !isCalculationField(field) && (!visible || isVisible(field))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue