diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte
index 6242034a27..1fab8bcd32 100644
--- a/packages/builder/src/components/backend/DataTable/DataTable.svelte
+++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte
@@ -23,6 +23,7 @@
schema,
name: $views.selected?.name,
}
+ $: isInternal = $tables.selected.type === "internal"
// Fetch rows for specified table
$: {
@@ -60,12 +61,16 @@
modalContentComponent={CreateEditRow}
/>
{/if}
-
+ {#if isInternal}
+
+ {/if}
{#if isUsersTable}
{/if}
-
+ {#if isInternal}
+
+ {/if}
{/if}
diff --git a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte
index 7db09f4480..b05053d2c6 100644
--- a/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte
+++ b/packages/builder/src/components/backend/DataTable/ViewDataTable.svelte
@@ -11,8 +11,8 @@
import HideAutocolumnButton from "./buttons/HideAutocolumnButton.svelte"
export let view = {}
- let hideAutocolumns = true
+ let hideAutocolumns = true
let data = []
let loading = false
@@ -27,7 +27,7 @@
async function fetchViewData(name, field, groupBy, calculation) {
const _tables = $tables.list
const allTableViews = _tables.map(table => table.views)
- const thisView = allTableViews.filter(
+ const thisView = $allTableViews..filter(
views => views != null && views[name] != null
)[0]
diff --git a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte
index be90635cec..58368aceed 100644
--- a/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte
+++ b/packages/builder/src/components/backend/TableNavigator/TableNavigator.svelte
@@ -1,6 +1,6 @@
@@ -23,14 +27,18 @@
+
+ {#if version}
+ Current Version: {version}
+ {/if}
+
diff --git a/packages/builder/src/stores/backend/datasources.js b/packages/builder/src/stores/backend/datasources.js
index 7a90d01807..89cd90b40f 100644
--- a/packages/builder/src/stores/backend/datasources.js
+++ b/packages/builder/src/stores/backend/datasources.js
@@ -16,7 +16,7 @@ export function createDatasourcesStore() {
init: async () => {
const response = await api.get(`/api/datasources`)
const json = await response.json()
- set({ list: json, selected: null })
+ set({ list: json })
},
fetch: async () => {
const response = await api.get(`/api/datasources`)
diff --git a/packages/builder/src/stores/backend/index.js b/packages/builder/src/stores/backend/index.js
index e020baaf4b..9820f55c94 100644
--- a/packages/builder/src/stores/backend/index.js
+++ b/packages/builder/src/stores/backend/index.js
@@ -6,4 +6,4 @@ export { permissions } from "./permissions"
export { roles } from "./roles"
export { datasources } from "./datasources"
export { integrations } from "./integrations"
-export { queries } from "./queries"
+export { queries } from "./queries"
\ No newline at end of file
diff --git a/packages/builder/src/stores/backend/queries.js b/packages/builder/src/stores/backend/queries.js
index 47ce365c61..e0a5c9d9fc 100644
--- a/packages/builder/src/stores/backend/queries.js
+++ b/packages/builder/src/stores/backend/queries.js
@@ -1,5 +1,5 @@
import { writable, get } from "svelte/store"
-import { datasources, integrations } from "./"
+import { datasources, integrations, tables } from "./"
import api from "builderStore/api"
export function createQueriesStore() {
@@ -59,6 +59,17 @@ export function createQueriesStore() {
...state,
selected: query.datasourceId,
}))
+ tables.update(state => ({
+ ...state,
+ selected: null,
+ }))
+ },
+ unselect: () => {
+ update(state => ({ ...state, selected: null }))
+ datasources.update(state => ({
+ ...state,
+ selected: null,
+ }))
},
delete: async query => {
const response = await api.delete(
diff --git a/packages/builder/src/stores/backend/tables.js b/packages/builder/src/stores/backend/tables.js
index 2c0d065919..18c748631a 100644
--- a/packages/builder/src/stores/backend/tables.js
+++ b/packages/builder/src/stores/backend/tables.js
@@ -1,5 +1,5 @@
import { writable, get } from "svelte/store"
-import { views } from "./"
+import { views, queries } from "./"
import { cloneDeep } from "lodash/fp"
import api from "builderStore/api"
@@ -26,6 +26,7 @@ export function createTablesStore() {
draft: cloneDeep(table),
}))
views.select({ name: table._id })
+ queries.unselect()
}
}
@@ -66,6 +67,7 @@ export function createTablesStore() {
return {
subscribe,
+ update,
fetch,
select,
save,
diff --git a/packages/server/src/api/controllers/dev.js b/packages/server/src/api/controllers/dev.js
index 068e1e59c0..ae7ab631d0 100644
--- a/packages/server/src/api/controllers/dev.js
+++ b/packages/server/src/api/controllers/dev.js
@@ -93,3 +93,7 @@ exports.revert = async ctx => {
ctx.throw(400, `Unable to revert. ${err}`)
}
}
+
+exports.getBudibaseVersion = async ctx => {
+ ctx.body = require("../../../package.json").version
+}
diff --git a/packages/server/src/api/controllers/row/external.js b/packages/server/src/api/controllers/row/external.js
index ed798ff062..297999126a 100644
--- a/packages/server/src/api/controllers/row/external.js
+++ b/packages/server/src/api/controllers/row/external.js
@@ -210,7 +210,7 @@ exports.validate = async () => {
return { valid: true }
}
-exports.fetchEnrichedRow = async ctx => {
+exports.fetchEnrichedRow = async () => {
// TODO: How does this work
throw "Not Implemented"
}
diff --git a/packages/server/src/api/controllers/table/index.js b/packages/server/src/api/controllers/table/index.js
index 2a44eefb15..60b5167f66 100644
--- a/packages/server/src/api/controllers/table/index.js
+++ b/packages/server/src/api/controllers/table/index.js
@@ -26,6 +26,7 @@ exports.fetch = async function (ctx) {
const internal = internalTables.rows.map(row => ({
...row.doc,
+ type: "internal",
sourceId: BudibaseInternalDB._id,
}))
@@ -38,6 +39,7 @@ exports.fetch = async function (ctx) {
const external = externalTables.rows.flatMap(row => {
return Object.values(row.doc.entities || {}).map(entity => ({
...entity,
+ type: "external",
sourceId: row.doc._id,
}))
})
diff --git a/packages/server/src/api/routes/dev.js b/packages/server/src/api/routes/dev.js
index bbc8147369..cd4c6e8fde 100644
--- a/packages/server/src/api/routes/dev.js
+++ b/packages/server/src/api/routes/dev.js
@@ -14,6 +14,7 @@ if (env.isDev() || env.isTest()) {
}
router
+ .get("/api/dev/version", authorized(BUILDER), controller.getBudibaseVersion)
.delete("/api/dev/:appId/lock", authorized(BUILDER), controller.clearLock)
.post("/api/dev/:appId/revert", authorized(BUILDER), controller.revert)
diff --git a/packages/server/src/integrations/base/sql.js b/packages/server/src/integrations/base/sql.js
index 20e722d0db..a99239cdd1 100644
--- a/packages/server/src/integrations/base/sql.js
+++ b/packages/server/src/integrations/base/sql.js
@@ -55,7 +55,7 @@ function addFilters(query, filters) {
return query
}
-function buildRelationships() {}
+// function buildRelationships() {}
function buildCreate(knex, json) {
const { endpoint, body } = json
diff --git a/packages/server/src/integrations/index.js b/packages/server/src/integrations/index.js
index bde154548e..4999f0c867 100644
--- a/packages/server/src/integrations/index.js
+++ b/packages/server/src/integrations/index.js
@@ -9,8 +9,6 @@ const airtable = require("./airtable")
const mysql = require("./mysql")
const arangodb = require("./arangodb")
const rest = require("./rest")
-// Plus
-const postgresPlus = require("../integrations/plus/postgres")
const DEFINITIONS = {
POSTGRES: postgres.schema,
diff --git a/packages/server/src/integrations/plus/index.js b/packages/server/src/integrations/plus/index.js
deleted file mode 100644
index f2b2ef3f07..0000000000
--- a/packages/server/src/integrations/plus/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-const postgres = require("./postgres")
-
-module.exports = {
- POSTGRES_PLUS: postgres,
-}
diff --git a/packages/server/src/integrations/plus/postgres.js b/packages/server/src/integrations/plus/postgres.js
deleted file mode 100644
index 87fd4c2cd2..0000000000
--- a/packages/server/src/integrations/plus/postgres.js
+++ /dev/null
@@ -1,135 +0,0 @@
-// const Sql = require("../base/sql")
-// const { Pool } = require("pg")
-// const { FieldTypes } = require("../../constants")
-// const { FIELD_TYPES } = require("../Integration")
-// const { SEPARATOR } = require("@budibase/auth/db")
-
-// const TYPE_MAP = {
-// text: FieldTypes.LONGFORM,
-// varchar: FieldTypes.STRING,
-// integer: FieldTypes.NUMBER,
-// bigint: FieldTypes.NUMBER,
-// decimal: FieldTypes.NUMBER,
-// smallint: FieldTypes.NUMBER,
-// timestamp: FieldTypes.DATETIME,
-// time: FieldTypes.DATETIME,
-// boolean: FieldTypes.BOOLEAN,
-// json: FIELD_TYPES.JSON,
-// }
-
-// const SCHEMA = {
-// friendlyName: "PostgreSQL",
-// description:
-// "PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.",
-// plus: true,
-// datasource: {
-// host: {
-// type: FIELD_TYPES.STRING,
-// default: "localhost",
-// required: true,
-// },
-// port: {
-// type: FIELD_TYPES.NUMBER,
-// required: true,
-// default: 5432,
-// },
-// database: {
-// type: FIELD_TYPES.STRING,
-// default: "postgres",
-// required: true,
-// },
-// user: {
-// type: FIELD_TYPES.STRING,
-// default: "root",
-// required: true,
-// },
-// password: {
-// type: FIELD_TYPES.PASSWORD,
-// default: "root",
-// required: true,
-// },
-// ssl: {
-// type: FIELD_TYPES.BOOLEAN,
-// default: false,
-// required: false,
-// },
-// },
-// }
-
-// class PostgresPlus extends Sql {
-// static pool
-// COLUMNS_SQL =
-// "select * from information_schema.columns where table_schema = 'public'"
-
-// PRIMARY_KEYS_SQL = `
-// select tc.table_schema, tc.table_name, kc.column_name as primary_key
-// from information_schema.table_constraints tc
-// join
-// information_schema.key_column_usage kc on kc.table_name = tc.table_name
-// and kc.table_schema = tc.table_schema
-// and kc.constraint_name = tc.constraint_name
-// where tc.constraint_type = 'PRIMARY KEY';
-// `
-
-// constructor(config, datasource) {
-// super("pg")
-// this.config = config
-// this.datasource = datasource
-
-// if (!this.pool) {
-// this.pool = new Pool(this.config)
-// }
-
-// this.client = this.pool
-// }
-
-// async init(datasourceId) {
-// let keys = []
-// try {
-// const primaryKeysResponse = await this.client.query(this.PRIMARY_KEYS_SQL)
-// for (let table of primaryKeysResponse.rows) {
-// keys.push(table.column_name || table.primary_key)
-// }
-// } catch (err) {
-// // TODO: this try catch method isn't right
-// keys = ["id"]
-// }
-
-// const columnsResponse = await this.client.query(this.COLUMNS_SQL)
-// const tables = {}
-
-// for (let column of columnsResponse.rows) {
-// const tableName = column.table_name
-// const columnName = column.column_name
-
-// // table key doesn't exist yet
-// if (!tables[tableName]) {
-// tables[tableName] = {
-// _id: `${datasourceId}${SEPARATOR}${tableName}`,
-// // TODO: this needs to accommodate composite keys
-// primary: keys,
-// name: tableName,
-// schema: {},
-// }
-// }
-
-// tables[tableName].schema[columnName] = {
-// name: columnName,
-// type: TYPE_MAP[column.data_type] || FIELD_TYPES.STRING,
-// }
-// }
-// this.tables = tables
-// }
-
-// async query(json) {
-// const operation = this._operation(json).toLowerCase()
-// const sql = this._query(json)
-// const response = await this.client.query(sql.sql, sql.bindings)
-// return response.rows.length ? response.rows : [{ [operation]: true }]
-// }
-// }
-
-// module.exports = {
-// schema: SCHEMA,
-// integration: PostgresPlus,
-// }
diff --git a/packages/server/src/integrations/postgres.js b/packages/server/src/integrations/postgres.js
index 47f163820d..2458afa333 100644
--- a/packages/server/src/integrations/postgres.js
+++ b/packages/server/src/integrations/postgres.js
@@ -2,7 +2,6 @@ const { Pool } = require("pg")
const { FIELD_TYPES } = require("./Integration")
const Sql = require("./base/sql")
const { FieldTypes } = require("../constants")
-const { SEPARATOR } = require("@budibase/auth/db")
const { buildExternalTableId } = require("./utils")
const SCHEMA = {
diff --git a/packages/standard-components/src/Button.svelte b/packages/standard-components/src/Button.svelte
index d307b25256..3739f5e3af 100644
--- a/packages/standard-components/src/Button.svelte
+++ b/packages/standard-components/src/Button.svelte
@@ -18,4 +18,4 @@
on:click={onClick}
>
{text || ""}
-
\ No newline at end of file
+