From 6063ab03b0c497bec33087e5521817de975cfde1 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Tue, 1 Feb 2022 20:59:26 +0000 Subject: [PATCH 01/17] Fixing issue with sql API after refactor. --- .../src/api/controllers/row/external.js | 75 ++++++------------- 1 file changed, 23 insertions(+), 52 deletions(-) diff --git a/packages/server/src/api/controllers/row/external.js b/packages/server/src/api/controllers/row/external.js index 0bd57d256f..66a1e30ca6 100644 --- a/packages/server/src/api/controllers/row/external.js +++ b/packages/server/src/api/controllers/row/external.js @@ -31,23 +31,21 @@ async function handleRequest(operation, tableId, opts = {}) { exports.handleRequest = handleRequest exports.patch = async ctx => { - const appId = ctx.appId const inputs = ctx.request.body const tableId = ctx.params.tableId const id = breakRowIdField(inputs._id) // don't save the ID to db delete inputs._id - return handleRequest(appId, DataSourceOperation.UPDATE, tableId, { + return handleRequest(DataSourceOperation.UPDATE, tableId, { id, row: inputs, }) } exports.save = async ctx => { - const appId = ctx.appId const inputs = ctx.request.body const tableId = ctx.params.tableId - return handleRequest(appId, DataSourceOperation.CREATE, tableId, { + return handleRequest(DataSourceOperation.CREATE, tableId, { row: inputs, }) } @@ -61,49 +59,35 @@ exports.fetchView = async ctx => { } exports.fetch = async ctx => { - const appId = ctx.appId const tableId = ctx.params.tableId - return handleRequest(appId, DataSourceOperation.READ, tableId) + return handleRequest(DataSourceOperation.READ, tableId) } exports.find = async ctx => { - const appId = ctx.appId const id = ctx.params.rowId const tableId = ctx.params.tableId - const response = await handleRequest( - appId, - DataSourceOperation.READ, - tableId, - { - id, - } - ) + const response = await handleRequest(DataSourceOperation.READ, tableId, { + id, + }) return response ? response[0] : response } exports.destroy = async ctx => { - const appId = ctx.appId const tableId = ctx.params.tableId const id = ctx.request.body._id - const { row } = await handleRequest( - appId, - DataSourceOperation.DELETE, - tableId, - { - id, - } - ) + const { row } = await handleRequest(DataSourceOperation.DELETE, tableId, { + id, + }) return { response: { ok: true }, row } } exports.bulkDestroy = async ctx => { - const appId = ctx.appId const { rows } = ctx.request.body const tableId = ctx.params.tableId let promises = [] for (let row of rows) { promises.push( - handleRequest(appId, DataSourceOperation.DELETE, tableId, { + handleRequest(DataSourceOperation.DELETE, tableId, { id: breakRowIdField(row._id), }) ) @@ -113,7 +97,6 @@ exports.bulkDestroy = async ctx => { } exports.search = async ctx => { - const appId = ctx.appId const tableId = ctx.params.tableId const { paginate, query, ...params } = ctx.request.body let { bookmark, limit } = params @@ -143,26 +126,21 @@ exports.search = async ctx => { [params.sort]: direction, } } - const rows = await handleRequest(appId, DataSourceOperation.READ, tableId, { + const rows = await handleRequest(DataSourceOperation.READ, tableId, { filters: query, sort, paginate: paginateObj, }) let hasNextPage = false if (paginate && rows.length === limit) { - const nextRows = await handleRequest( - appId, - DataSourceOperation.READ, - tableId, - { - filters: query, - sort, - paginate: { - limit: 1, - page: bookmark * limit + 1, - }, - } - ) + const nextRows = await handleRequest(DataSourceOperation.READ, tableId, { + filters: query, + sort, + paginate: { + limit: 1, + page: bookmark * limit + 1, + }, + }) hasNextPage = nextRows.length > 0 } // need wrapper object for bookmarks etc when paginating @@ -175,7 +153,6 @@ exports.validate = async () => { } exports.fetchEnrichedRow = async ctx => { - const appId = ctx.appId const id = ctx.params.rowId const tableId = ctx.params.tableId const { datasourceId, tableName } = breakExternalTableId(tableId) @@ -185,15 +162,10 @@ exports.fetchEnrichedRow = async ctx => { ctx.throw(400, "Datasource has not been configured for plus API.") } const tables = datasource.entities - const response = await handleRequest( - appId, - DataSourceOperation.READ, - tableId, - { - id, - datasource, - } - ) + const response = await handleRequest(DataSourceOperation.READ, tableId, { + id, + datasource, + }) const table = tables[tableName] const row = response[0] // this seems like a lot of work, but basically we need to dig deeper for the enrich @@ -212,7 +184,6 @@ exports.fetchEnrichedRow = async ctx => { // don't support composite keys right now const linkedIds = links.map(link => breakRowIdField(link._id)[0]) row[fieldName] = await handleRequest( - appId, DataSourceOperation.READ, linkedTableId, { From cf3e0f0fdce541b65d7e206aa114bfcf18e3a2e3 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 2 Feb 2022 10:59:16 +0000 Subject: [PATCH 02/17] v1.0.49-alpha.8 --- lerna.json | 2 +- packages/backend-core/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 6 +++--- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index 8d6a1032c9..21b2cc06d9 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 3d837779b8..c2a1a80e01 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 5cc3ccebeb..6d96b5c6fa 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 681c359d2c..0aeed0516c 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "license": "GPL-3.0", "private": true, "scripts": { @@ -66,10 +66,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.49-alpha.7", - "@budibase/client": "^1.0.49-alpha.7", + "@budibase/bbui": "^1.0.49-alpha.8", + "@budibase/client": "^1.0.49-alpha.8", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.49-alpha.7", + "@budibase/string-templates": "^1.0.49-alpha.8", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 29890fc479..11302905e4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 0595ae93e3..00a750e09e 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.49-alpha.7", + "@budibase/bbui": "^1.0.49-alpha.8", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.49-alpha.7", + "@budibase/string-templates": "^1.0.49-alpha.8", "regexparam": "^1.3.0", "rollup-plugin-polyfill-node": "^0.8.0", "shortid": "^2.2.15", diff --git a/packages/server/package.json b/packages/server/package.json index 0ec6496bab..50295acd8f 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,9 +70,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/backend-core": "^1.0.49-alpha.7", - "@budibase/client": "^1.0.49-alpha.7", - "@budibase/string-templates": "^1.0.49-alpha.7", + "@budibase/backend-core": "^1.0.49-alpha.8", + "@budibase/client": "^1.0.49-alpha.8", + "@budibase/string-templates": "^1.0.49-alpha.8", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 290e75d652..2247899b24 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index d7ec889ae0..e03eab38c2 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.49-alpha.7", + "version": "1.0.49-alpha.8", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -34,8 +34,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.49-alpha.7", - "@budibase/string-templates": "^1.0.49-alpha.7", + "@budibase/backend-core": "^1.0.49-alpha.8", + "@budibase/string-templates": "^1.0.49-alpha.8", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0", From 168a126e2a6a2f22b7241cbb286600b5488cce9b Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 2 Feb 2022 18:15:17 +0000 Subject: [PATCH 03/17] Updating the SQL core to allow it to handle multiple relationships between the same two tables. --- .../PlusConfigForm.svelte | 44 ++++++----- .../Datasources/CreateEditRelationship.svelte | 75 ++++++++----------- .../scripts/integrations/postgres/init.sql | 17 +++-- .../api/controllers/row/ExternalRequest.ts | 13 ++++ packages/server/src/integrations/base/sql.ts | 71 ++++++++++++++---- 5 files changed, 133 insertions(+), 87 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte index 8805505c8d..45bc5ff330 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte @@ -188,29 +188,27 @@ {:else} No tables found. {/if} -{#if plusTables?.length !== 0 && integration.relationships} - -
- Relationships - -
- - Tell budibase how your tables are related to get even more smart features. - - {#if relationshipInfo && relationshipInfo.length > 0} - openRelationshipModal(detail.from, detail.to)} - schema={relationshipSchema} - data={relationshipInfo} - allowEditColumns={false} - allowEditRows={false} - allowSelectRows={false} - /> - {:else} - No relationships configured. - {/if} + +
+ Relationships + +
+ + Tell budibase how your tables are related to get even more smart features. + +{#if relationshipInfo && relationshipInfo.length > 0} +
openRelationshipModal(detail.from, detail.to)} + schema={relationshipSchema} + data={relationshipInfo} + allowEditColumns={false} + allowEditRows={false} + allowSelectRows={false} + /> +{:else} + No relationships configured. {/if}