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 { db as dbCore } from "@budibase/backend-core"
|
||||
import tracer from "dd-trace"
|
||||
import { removeInvalidFilters } from "./queryUtils"
|
||||
|
||||
export { isValidFilter } from "../../../integrations/utils"
|
||||
|
||||
|
@ -86,6 +87,11 @@ export async function search(
|
|||
options.fields = visibleTableFields
|
||||
}
|
||||
|
||||
options.query = removeInvalidFilters(options.query, [
|
||||
"_id",
|
||||
...options.fields,
|
||||
])
|
||||
|
||||
let result: SearchResponse<Row>
|
||||
if (isExternalTable) {
|
||||
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 { search } from "../../../../../sdk/app/rows/search"
|
||||
|
@ -53,15 +60,25 @@ describe.each([
|
|||
})
|
||||
|
||||
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(
|
||||
tableForDatasource(datasource, {
|
||||
primary: ["id"],
|
||||
schema: {
|
||||
id: {
|
||||
name: "id",
|
||||
type: FieldType.NUMBER,
|
||||
autocolumn: true,
|
||||
},
|
||||
id: idFieldSchema,
|
||||
name: {
|
||||
name: "name",
|
||||
type: FieldType.STRING,
|
||||
|
@ -256,7 +273,7 @@ describe.each([
|
|||
[["id", "name", "age"], 3],
|
||||
[["name", "age"], 10],
|
||||
])(
|
||||
"cannot query by non search fields",
|
||||
"cannot query by non search fields (fields: %s)",
|
||||
async (queryFields, expectedRows) => {
|
||||
await config.doInContext(config.appId, async () => {
|
||||
const { rows } = await search({
|
||||
|
|
Loading…
Reference in New Issue