Return _viewId when searching

This commit is contained in:
Adria Navarro 2023-07-25 17:43:31 +02:00
parent 2c6725404f
commit b69e18ab70
2 changed files with 7 additions and 3 deletions

View File

@ -269,7 +269,7 @@ export async function searchView(ctx: Ctx<void, SearchResponse>) {
undefined undefined
ctx.status = 200 ctx.status = 200
ctx.body = await quotas.addQuery( const result = await quotas.addQuery(
() => () =>
sdk.rows.search({ sdk.rows.search({
tableId: view.tableId, tableId: view.tableId,
@ -281,6 +281,9 @@ export async function searchView(ctx: Ctx<void, SearchResponse>) {
datasourceId: view.tableId, datasourceId: view.tableId,
} }
) )
result.rows.forEach(r => (r._viewId = view.id))
ctx.body = result
} }
export async function validate(ctx: Ctx) { export async function validate(ctx: Ctx) {

View File

@ -986,16 +986,17 @@ describe("/rows", () => {
) )
} }
const createViewResponse = await config.api.viewV2.create({ const view = await config.api.viewV2.create({
columns: { name: { visible: true } }, columns: { name: { visible: true } },
}) })
const response = await config.api.viewV2.search(createViewResponse.id) const response = await config.api.viewV2.search(view.id)
expect(response.body.rows).toHaveLength(10) expect(response.body.rows).toHaveLength(10)
expect(response.body.rows).toEqual( expect(response.body.rows).toEqual(
expect.arrayContaining( expect.arrayContaining(
rows.map(r => ({ rows.map(r => ({
...expectAnyInternalColsAttributes, ...expectAnyInternalColsAttributes,
_viewId: view.id,
name: r.name, name: r.name,
})) }))
) )