From d16015587fcb00a13132e35dddb66e67bc5604db Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 24 Feb 2021 16:55:06 +0000 Subject: [PATCH] Fixing an issue where the table that a view was attached to was not being retrieved correctly, inhibiting the ability to enrich with relationships. --- packages/server/src/api/controllers/row.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row.js b/packages/server/src/api/controllers/row.js index 54f4e4508e..4ce664413e 100644 --- a/packages/server/src/api/controllers/row.js +++ b/packages/server/src/api/controllers/row.js @@ -202,6 +202,11 @@ exports.fetchView = async function(ctx) { const db = new CouchDB(appId) const { calculation, group, field } = ctx.query + const designDoc = await db.get("_design/database") + const viewInfo = designDoc.views[viewName] + if (!viewInfo) { + ctx.throw(400, "View does not exist.") + } const response = await db.query(`database/${viewName}`, { include_docs: !calculation, group, @@ -211,7 +216,7 @@ exports.fetchView = async function(ctx) { response.rows = response.rows.map(row => row.doc) let table try { - table = await db.get(ctx.params.tableId) + table = await db.get(viewInfo.meta.tableId) } catch (err) { table = { schema: {},