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

View File

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