1
0
Fork 0
mirror of synced 2024-09-20 11:27:56 +12:00
This commit is contained in:
Adria Navarro 2024-08-23 12:28:02 +02:00
parent 02fdbae7ac
commit ccf734486f
2 changed files with 35 additions and 6 deletions

View file

@ -9,7 +9,13 @@ import {
import tk from "timekeeper"
import emitter from "../../../../src/events"
import { outputProcessing } from "../../../utilities/rowProcessor"
import { context, InternalTable, tenancy } from "@budibase/backend-core"
import {
context,
InternalTable,
tenancy,
withEnv as withCoreEnv,
setEnv as setCoreEnv,
} from "@budibase/backend-core"
import { quotas } from "@budibase/pro"
import {
AttachmentFieldMetadata,
@ -69,6 +75,7 @@ async function waitForEvent(
describe.each([
["internal", undefined],
["sqs", undefined],
[DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
[DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
[DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
@ -76,6 +83,7 @@ describe.each([
[DatabaseName.ORACLE, getDatasource(DatabaseName.ORACLE)],
])("/rows (%s)", (providerType, dsProvider) => {
const isInternal = dsProvider === undefined
const isSqs = providerType === "sqs"
const isMSSQL = providerType === DatabaseName.SQL_SERVER
const isOracle = providerType === DatabaseName.ORACLE
const config = setup.getConfig()
@ -83,9 +91,17 @@ describe.each([
let table: Table
let datasource: Datasource | undefined
let client: Knex | undefined
let envCleanup: (() => void) | undefined
beforeAll(async () => {
await config.init()
await withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, () => config.init())
if (isSqs) {
envCleanup = setCoreEnv({
SQS_SEARCH_ENABLE: "true",
SQS_SEARCH_ENABLE_TENANTS: [config.getTenantId()],
})
}
if (dsProvider) {
const rawDatasource = await dsProvider
datasource = await config.createDatasource({
@ -97,6 +113,9 @@ describe.each([
afterAll(async () => {
setup.afterAll()
if (envCleanup) {
envCleanup()
}
})
function saveTableRequest(
@ -2413,11 +2432,12 @@ describe.each([
let auxData: Row[] = []
beforeAll(async () => {
const aux2Table = await config.api.table.save(defaultTable())
const aux2Table = await config.api.table.save(saveTableRequest())
const aux2Data = await config.api.row.save(aux2Table._id!, {})
const auxTable = await config.api.table.save(
defaultTable({
saveTableRequest({
primaryDisplay: "name",
schema: {
name: {
name: "name",
@ -2466,7 +2486,7 @@ describe.each([
}
const table = await config.api.table.save(
defaultTable({
saveTableRequest({
schema: {
title: {
name: "title",

View file

@ -3,6 +3,7 @@ import { fixAutoColumnSubType, processFormulas } from "./utils"
import {
cache,
context,
db,
HTTPError,
objectStore,
utils,
@ -349,11 +350,19 @@ export async function outputProcessing<T extends Row[] | Row>(
}
// remove null properties to match internal API
const isExternal = isExternalTableID(table._id!)
if (isExternal) {
if (isExternal || db.isSqsEnabledForTenant()) {
for (const row of enriched) {
for (const key of Object.keys(row)) {
if (row[key] === null) {
delete row[key]
} else if (row[key] && table.schema[key]?.type === FieldType.LINK) {
for (const link of row[key] || []) {
for (const linkKey of Object.keys(link)) {
if (link[linkKey] === null) {
delete link[linkKey]
}
}
}
}
}
}