Fix search tests.
This commit is contained in:
parent
e6fc3dbff4
commit
3c6e2ff2d7
|
@ -3554,6 +3554,8 @@ if (descriptions.length) {
|
||||||
}).toContainExactly([row])
|
}).toContainExactly([row])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
isInternal &&
|
||||||
|
describe("search by _id for relations", () => {
|
||||||
it("can filter by the related _id", async () => {
|
it("can filter by the related _id", async () => {
|
||||||
await expectSearch({
|
await expectSearch({
|
||||||
query: {
|
query: {
|
||||||
|
@ -3576,6 +3578,7 @@ if (descriptions.length) {
|
||||||
}).toFindNothing()
|
}).toFindNothing()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
!isInternal &&
|
!isInternal &&
|
||||||
describe("search by composite key", () => {
|
describe("search by composite key", () => {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import sdk from "../../../sdk"
|
import sdk from "../../../sdk"
|
||||||
|
import { isInternal } from "../tables/utils"
|
||||||
|
|
||||||
export const removeInvalidFilters = (
|
export const removeInvalidFilters = (
|
||||||
filters: SearchFilters,
|
filters: SearchFilters,
|
||||||
|
@ -69,8 +70,11 @@ export const getQueryableFields = async (
|
||||||
fromTables: string[],
|
fromTables: string[],
|
||||||
opts?: { noRelationships?: boolean }
|
opts?: { noRelationships?: boolean }
|
||||||
): Promise<string[]> => {
|
): Promise<string[]> => {
|
||||||
// Querying by _id is always allowed, even if it's never part of the schema
|
const result = []
|
||||||
const result = ["_id"]
|
if (isInternal({ table })) {
|
||||||
|
result.push("_id")
|
||||||
|
}
|
||||||
|
|
||||||
for (const field of Object.keys(table.schema).filter(
|
for (const field of Object.keys(table.schema).filter(
|
||||||
f => allowedFields.includes(f) && table.schema[f].visible !== false
|
f => allowedFields.includes(f) && table.schema[f].visible !== false
|
||||||
)) {
|
)) {
|
||||||
|
@ -114,7 +118,8 @@ export const getQueryableFields = async (
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = []
|
// Querying by _id is always allowed, even if it's never part of the schema
|
||||||
|
const result = ["_id"]
|
||||||
|
|
||||||
if (fields == null) {
|
if (fields == null) {
|
||||||
fields = Object.keys(table.schema)
|
fields = Object.keys(table.schema)
|
||||||
|
|
Loading…
Reference in New Issue