Run tests for all

This commit is contained in:
Adria Navarro 2024-10-16 12:38:38 +02:00
parent 83ffee3194
commit 7266fb3c1b
2 changed files with 37 additions and 38 deletions

View File

@ -216,15 +216,15 @@ export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
await context.ensureSnippetContext(true) await context.ensureSnippetContext(true)
let enrichedQuery: SearchFilters = await utils.enrichSearchContext( let { query } = ctx.request.body
{ ...ctx.request.body.query }, if (!isPlainObject(query)) {
{ const allTables = await sdk.tables.getAllTables()
user: sdk.users.getUserContextBindings(ctx.user), query = replaceTableNamesInFilters(tableId, query, allTables)
} }
)
const allTables = await sdk.tables.getAllTables() let enrichedQuery: SearchFilters = await utils.enrichSearchContext(query, {
enrichedQuery = replaceTableNamesInFilters(tableId, enrichedQuery, allTables) user: sdk.users.getUserContextBindings(ctx.user),
})
const searchParams: RowSearchParams = { const searchParams: RowSearchParams = {
...ctx.request.body, ...ctx.request.body,

View File

@ -2567,7 +2567,8 @@ describe.each([
expect(response.rows[0].productCat).toBeArrayOfSize(11) expect(response.rows[0].productCat).toBeArrayOfSize(11)
}) })
}) })
;(isSqs || isLucene) &&
isSql &&
describe("relations to same table", () => { describe("relations to same table", () => {
let relatedTable: string, relatedRows: Row[] let relatedTable: string, relatedRows: Row[]
@ -2637,38 +2638,36 @@ describe.each([
]) ])
}) })
isSqs && it("should be able to filter via the first relation field with equal", async () => {
it("should be able to filter via the first relation field with equal", async () => { await expectSearch({
await expectSearch({ query: {
query: { equal: {
equal: { ["related1.name"]: "baz",
["related1.name"]: "baz",
},
}, },
}).toContainExactly([ },
{ }).toContainExactly([
name: "test2", {
related1: [{ _id: relatedRows[2]._id }], name: "test2",
}, related1: [{ _id: relatedRows[2]._id }],
]) },
}) ])
})
isSqs && it("should be able to filter via the second relation field with not equal", async () => {
it("should be able to filter via the second relation field with not equal", async () => { await expectSearch({
await expectSearch({ query: {
query: { notEqual: {
notEqual: { ["1:related2.name"]: "foo",
["1:related2.name"]: "foo", ["2:related2.name"]: "baz",
["2:related2.name"]: "baz", ["3:related2.name"]: "boo",
["3:related2.name"]: "boo",
},
}, },
}).toContainExactly([ },
{ }).toContainExactly([
name: "test", {
}, name: "test",
]) },
}) ])
})
}) })
isInternal && isInternal &&