Implement query
This commit is contained in:
parent
5b13e53a3b
commit
48486cdaa4
|
@ -14,6 +14,7 @@ import sdk from "../../index"
|
||||||
import { searchInputMapping } from "./search/utils"
|
import { searchInputMapping } from "./search/utils"
|
||||||
import { db as dbCore } from "@budibase/backend-core"
|
import { db as dbCore } from "@budibase/backend-core"
|
||||||
import tracer from "dd-trace"
|
import tracer from "dd-trace"
|
||||||
|
import { removeInvalidFilters } from "./queryUtils"
|
||||||
|
|
||||||
export { isValidFilter } from "../../../integrations/utils"
|
export { isValidFilter } from "../../../integrations/utils"
|
||||||
|
|
||||||
|
@ -86,6 +87,11 @@ export async function search(
|
||||||
options.fields = visibleTableFields
|
options.fields = visibleTableFields
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options.query = removeInvalidFilters(options.query, [
|
||||||
|
"_id",
|
||||||
|
...options.fields,
|
||||||
|
])
|
||||||
|
|
||||||
let result: SearchResponse<Row>
|
let result: SearchResponse<Row>
|
||||||
if (isExternalTable) {
|
if (isExternalTable) {
|
||||||
span?.addTags({ searchType: "external" })
|
span?.addTags({ searchType: "external" })
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
import { Datasource, FieldType, Table } from "@budibase/types"
|
import {
|
||||||
|
AutoColumnFieldMetadata,
|
||||||
|
AutoFieldSubType,
|
||||||
|
Datasource,
|
||||||
|
FieldType,
|
||||||
|
NumberFieldMetadata,
|
||||||
|
Table,
|
||||||
|
} from "@budibase/types"
|
||||||
|
|
||||||
import TestConfiguration from "../../../../../tests/utilities/TestConfiguration"
|
import TestConfiguration from "../../../../../tests/utilities/TestConfiguration"
|
||||||
import { search } from "../../../../../sdk/app/rows/search"
|
import { search } from "../../../../../sdk/app/rows/search"
|
||||||
|
@ -53,15 +60,25 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const idFieldSchema: NumberFieldMetadata | AutoColumnFieldMetadata =
|
||||||
|
isInternal
|
||||||
|
? {
|
||||||
|
name: "id",
|
||||||
|
type: FieldType.AUTO,
|
||||||
|
subtype: AutoFieldSubType.AUTO_ID,
|
||||||
|
autocolumn: true,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
name: "id",
|
||||||
|
type: FieldType.NUMBER,
|
||||||
|
autocolumn: true,
|
||||||
|
}
|
||||||
|
|
||||||
table = await config.api.table.save(
|
table = await config.api.table.save(
|
||||||
tableForDatasource(datasource, {
|
tableForDatasource(datasource, {
|
||||||
primary: ["id"],
|
primary: ["id"],
|
||||||
schema: {
|
schema: {
|
||||||
id: {
|
id: idFieldSchema,
|
||||||
name: "id",
|
|
||||||
type: FieldType.NUMBER,
|
|
||||||
autocolumn: true,
|
|
||||||
},
|
|
||||||
name: {
|
name: {
|
||||||
name: "name",
|
name: "name",
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
|
@ -256,7 +273,7 @@ describe.each([
|
||||||
[["id", "name", "age"], 3],
|
[["id", "name", "age"], 3],
|
||||||
[["name", "age"], 10],
|
[["name", "age"], 10],
|
||||||
])(
|
])(
|
||||||
"cannot query by non search fields",
|
"cannot query by non search fields (fields: %s)",
|
||||||
async (queryFields, expectedRows) => {
|
async (queryFields, expectedRows) => {
|
||||||
await config.doInContext(config.appId, async () => {
|
await config.doInContext(config.appId, async () => {
|
||||||
const { rows } = await search({
|
const { rows } = await search({
|
||||||
|
|
Loading…
Reference in New Issue