From d16015587fcb00a13132e35dddb66e67bc5604db Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 24 Feb 2021 16:55:06 +0000 Subject: [PATCH 1/4] 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: {}, From a69cc4950142e23855d88b763239c15e99effd88 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 24 Feb 2021 17:21:53 +0000 Subject: [PATCH 2/4] Updating group by functionality, so that relationships aren't an option. --- .../backend/DataTable/popovers/GroupByPopover.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DataTable/popovers/GroupByPopover.svelte b/packages/builder/src/components/backend/DataTable/popovers/GroupByPopover.svelte index 36fde06d77..8c3b81dd53 100644 --- a/packages/builder/src/components/backend/DataTable/popovers/GroupByPopover.svelte +++ b/packages/builder/src/components/backend/DataTable/popovers/GroupByPopover.svelte @@ -2,6 +2,7 @@ import { Button, Input, Select } from "@budibase/bbui" import { backendUiStore } from "builderStore" import { notifier } from "builderStore/store/notifications" + import { FIELDS } from "constants/backend" export let view = {} export let onClosed @@ -9,7 +10,11 @@ $: viewTable = $backendUiStore.tables.find( ({ _id }) => _id === $backendUiStore.selectedView.tableId ) - $: fields = viewTable && Object.keys(viewTable.schema) + $: fields = + viewTable && + Object.entries(viewTable.schema) + .filter(entry => entry[1].type !== FIELDS.LINK.type) + .map(([key]) => key) function saveView() { backendUiStore.actions.views.save(view) From 73636d8f784253cca77ccb7d71810ee8c2728b8c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 24 Feb 2021 17:59:55 +0000 Subject: [PATCH 3/4] Copying the table on way in so that after function call the input table can be copied to output table to decide whether to save. --- packages/server/src/utilities/rowProcessor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/server/src/utilities/rowProcessor.js b/packages/server/src/utilities/rowProcessor.js index 362f7e8820..32c488aed7 100644 --- a/packages/server/src/utilities/rowProcessor.js +++ b/packages/server/src/utilities/rowProcessor.js @@ -136,6 +136,8 @@ exports.coerce = (row, type) => { */ exports.inputProcessing = (user, table, row) => { let clonedRow = cloneDeep(row) + // need to copy the table so it can be differenced on way out + const copiedTable = cloneDeep(table) for (let [key, value] of Object.entries(clonedRow)) { const field = table.schema[key] if (!field) { @@ -144,7 +146,7 @@ exports.inputProcessing = (user, table, row) => { clonedRow[key] = exports.coerce(value, field.type) } // handle auto columns - this returns an object like {table, row} - return processAutoColumn(user, table, clonedRow) + return processAutoColumn(user, copiedTable, clonedRow) } /** From ed6a77a55d50ea5fe85a88c1f0086b0f4b44356b Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 24 Feb 2021 21:58:38 +0000 Subject: [PATCH 4/4] mysql key length --- packages/server/src/integrations/mysql.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/integrations/mysql.js b/packages/server/src/integrations/mysql.js index 411ea181ed..af1a1baf92 100644 --- a/packages/server/src/integrations/mysql.js +++ b/packages/server/src/integrations/mysql.js @@ -55,7 +55,7 @@ const SCHEMA = { class MySQLIntegration { constructor(config) { this.config = config - if (Object.keys(config.ssl) === 0) { + if (Object.keys(config.ssl).length === 0) { delete config.ssl } this.client = mysql.createConnection(config)