Cleanup SQS feature usages
This commit is contained in:
parent
04f1e2bebb
commit
42f27bacb2
|
@ -10,7 +10,6 @@ import {
|
||||||
DatabaseQueryOpts,
|
DatabaseQueryOpts,
|
||||||
DBError,
|
DBError,
|
||||||
Document,
|
Document,
|
||||||
FeatureFlag,
|
|
||||||
isDocument,
|
isDocument,
|
||||||
RowResponse,
|
RowResponse,
|
||||||
RowValue,
|
RowValue,
|
||||||
|
@ -27,7 +26,6 @@ import { SQLITE_DESIGN_DOC_ID } from "../../constants"
|
||||||
import { DDInstrumentedDatabase } from "../instrumentation"
|
import { DDInstrumentedDatabase } from "../instrumentation"
|
||||||
import { checkSlashesInUrl } from "../../helpers"
|
import { checkSlashesInUrl } from "../../helpers"
|
||||||
import { sqlLog } from "../../sql/utils"
|
import { sqlLog } from "../../sql/utils"
|
||||||
import { flags } from "../../features"
|
|
||||||
|
|
||||||
const DATABASE_NOT_FOUND = "Database does not exist."
|
const DATABASE_NOT_FOUND = "Database does not exist."
|
||||||
|
|
||||||
|
@ -456,10 +454,7 @@ export class DatabaseImpl implements Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
async destroy() {
|
async destroy() {
|
||||||
if (
|
if (await this.exists(SQLITE_DESIGN_DOC_ID)) {
|
||||||
(await flags.isEnabled(FeatureFlag.SQS)) &&
|
|
||||||
(await this.exists(SQLITE_DESIGN_DOC_ID))
|
|
||||||
) {
|
|
||||||
// delete the design document, then run the cleanup operation
|
// delete the design document, then run the cleanup operation
|
||||||
const definition = await this.get<SQLiteDefinition>(SQLITE_DESIGN_DOC_ID)
|
const definition = await this.get<SQLiteDefinition>(SQLITE_DESIGN_DOC_ID)
|
||||||
// remove all tables - save the definition then trigger a cleanup
|
// remove all tables - save the definition then trigger a cleanup
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 297fdc937e9c650b4964fc1a942b60022b195865
|
Subproject commit 14f9c8a92517bdd08ff29ad39e92cb90d4b2c02f
|
|
@ -15,12 +15,11 @@ import { getViews, saveView } from "../view/utils"
|
||||||
import viewTemplate from "../view/viewBuilder"
|
import viewTemplate from "../view/viewBuilder"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import { quotas } from "@budibase/pro"
|
import { quotas } from "@budibase/pro"
|
||||||
import { context, events, features } from "@budibase/backend-core"
|
import { context, events } from "@budibase/backend-core"
|
||||||
import {
|
import {
|
||||||
AutoFieldSubType,
|
AutoFieldSubType,
|
||||||
Database,
|
Database,
|
||||||
Datasource,
|
Datasource,
|
||||||
FeatureFlag,
|
|
||||||
FieldSchema,
|
FieldSchema,
|
||||||
FieldType,
|
FieldType,
|
||||||
NumberFieldMetadata,
|
NumberFieldMetadata,
|
||||||
|
@ -330,9 +329,8 @@ class TableSaveFunctions {
|
||||||
importRows: this.importRows,
|
importRows: this.importRows,
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
})
|
})
|
||||||
if (await features.flags.isEnabled(FeatureFlag.SQS)) {
|
|
||||||
await sdk.tables.sqs.addTable(table)
|
await sdk.tables.sqs.addTable(table)
|
||||||
}
|
|
||||||
return table
|
return table
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,9 +522,8 @@ export async function internalTableCleanup(table: Table, rows?: Row[]) {
|
||||||
if (rows) {
|
if (rows) {
|
||||||
await AttachmentCleanup.tableDelete(table, rows)
|
await AttachmentCleanup.tableDelete(table, rows)
|
||||||
}
|
}
|
||||||
if (await features.flags.isEnabled(FeatureFlag.SQS)) {
|
|
||||||
await sdk.tables.sqs.removeTable(table)
|
await sdk.tables.sqs.removeTable(table)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _TableSaveFunctions = TableSaveFunctions
|
const _TableSaveFunctions = TableSaveFunctions
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { context, features } from "@budibase/backend-core"
|
import { context } from "@budibase/backend-core"
|
||||||
import { getTableParams } from "../../../db/utils"
|
import { getTableParams } from "../../../db/utils"
|
||||||
import {
|
import {
|
||||||
breakExternalTableId,
|
breakExternalTableId,
|
||||||
|
@ -12,7 +12,6 @@ import {
|
||||||
TableResponse,
|
TableResponse,
|
||||||
TableSourceType,
|
TableSourceType,
|
||||||
TableViewsResponse,
|
TableViewsResponse,
|
||||||
FeatureFlag,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import datasources from "../datasources"
|
import datasources from "../datasources"
|
||||||
import sdk from "../../../sdk"
|
import sdk from "../../../sdk"
|
||||||
|
@ -39,10 +38,7 @@ export async function processTable(table: Table): Promise<Table> {
|
||||||
type: "table",
|
type: "table",
|
||||||
sourceId: table.sourceId || INTERNAL_TABLE_SOURCE_ID,
|
sourceId: table.sourceId || INTERNAL_TABLE_SOURCE_ID,
|
||||||
sourceType: TableSourceType.INTERNAL,
|
sourceType: TableSourceType.INTERNAL,
|
||||||
}
|
sql: true,
|
||||||
const sqsEnabled = await features.flags.isEnabled(FeatureFlag.SQS)
|
|
||||||
if (sqsEnabled) {
|
|
||||||
processed.sql = true
|
|
||||||
}
|
}
|
||||||
return processed
|
return processed
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { fixAutoColumnSubType, processFormulas } from "./utils"
|
||||||
import {
|
import {
|
||||||
cache,
|
cache,
|
||||||
context,
|
context,
|
||||||
features,
|
|
||||||
HTTPError,
|
HTTPError,
|
||||||
objectStore,
|
objectStore,
|
||||||
utils,
|
utils,
|
||||||
|
@ -19,7 +18,6 @@ import {
|
||||||
Table,
|
Table,
|
||||||
User,
|
User,
|
||||||
ViewV2,
|
ViewV2,
|
||||||
FeatureFlag,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import {
|
import {
|
||||||
|
@ -417,44 +415,42 @@ export async function coreOutputProcessing(
|
||||||
rows = await processFormulas(table, rows, { dynamic: true })
|
rows = await processFormulas(table, rows, { dynamic: true })
|
||||||
|
|
||||||
// remove null properties to match internal API
|
// remove null properties to match internal API
|
||||||
const isExternal = isExternalTableID(table._id!)
|
for (const row of rows) {
|
||||||
if (isExternal || (await features.flags.isEnabled(FeatureFlag.SQS))) {
|
for (const key of Object.keys(row)) {
|
||||||
for (const row of rows) {
|
if (row[key] === null) {
|
||||||
for (const key of Object.keys(row)) {
|
delete row[key]
|
||||||
if (row[key] === null) {
|
} else if (row[key] && table.schema[key]?.type === FieldType.LINK) {
|
||||||
delete row[key]
|
for (const link of row[key] || []) {
|
||||||
} else if (row[key] && table.schema[key]?.type === FieldType.LINK) {
|
for (const linkKey of Object.keys(link)) {
|
||||||
for (const link of row[key] || []) {
|
if (link[linkKey] === null) {
|
||||||
for (const linkKey of Object.keys(link)) {
|
delete link[linkKey]
|
||||||
if (link[linkKey] === null) {
|
|
||||||
delete link[linkKey]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdk.views.isView(source)) {
|
|
||||||
const calculationFields = Object.keys(
|
|
||||||
helpers.views.calculationFields(source)
|
|
||||||
)
|
|
||||||
|
|
||||||
// We ensure all calculation fields are returned as numbers. During the
|
|
||||||
// testing of this feature it was discovered that the COUNT operation
|
|
||||||
// returns a string for MySQL, MariaDB, and Postgres. But given that all
|
|
||||||
// calculation fields should be numbers, we blanket make sure of that
|
|
||||||
// here.
|
|
||||||
for (const key of calculationFields) {
|
|
||||||
for (const row of rows) {
|
|
||||||
if (typeof row[key] === "string") {
|
|
||||||
row[key] = parseFloat(row[key])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sdk.views.isView(source)) {
|
||||||
|
const calculationFields = Object.keys(
|
||||||
|
helpers.views.calculationFields(source)
|
||||||
|
)
|
||||||
|
|
||||||
|
// We ensure all calculation fields are returned as numbers. During the
|
||||||
|
// testing of this feature it was discovered that the COUNT operation
|
||||||
|
// returns a string for MySQL, MariaDB, and Postgres. But given that all
|
||||||
|
// calculation fields should be numbers, we blanket make sure of that
|
||||||
|
// here.
|
||||||
|
for (const key of calculationFields) {
|
||||||
|
for (const row of rows) {
|
||||||
|
if (typeof row[key] === "string") {
|
||||||
|
row[key] = parseFloat(row[key])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const isExternal = isExternalTableID(table._id!)
|
||||||
if (!isUserMetadataTable(table._id!)) {
|
if (!isUserMetadataTable(table._id!)) {
|
||||||
const protectedColumns = isExternal
|
const protectedColumns = isExternal
|
||||||
? PROTECTED_EXTERNAL_COLUMNS
|
? PROTECTED_EXTERNAL_COLUMNS
|
||||||
|
|
Loading…
Reference in New Issue