Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: PR requested changes

mertmitc4692338511e
diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts
index 532a16afbe..cc75cbd27e 100644
--- a/packages/nocodb/src/db/BaseModelSqlv2.ts
+++ b/packages/nocodb/src/db/BaseModelSqlv2.ts
@@ -95,6 +95,7 @@ import {
isPrimitiveType,
nanoidv2,
populatePk,
+ transformObjectKeys,
validateFuncOnColumn,
} from '~/helpers/dbHelpers';
import { defaultLimitConfig } from '~/helpers/extractLimitAndOffset';
@@ -5413,7 +5414,8 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
const col = await Column.get(this.context, { colId: k });
return { id: k, title: col?.title };
} catch (e) {
- throw e;
+ // ignore error to avoid breaking the entire response
+ return {};
}
});
@@ -5447,7 +5449,7 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
// Transform array of objects
transformedItem[targetKey] = value.map((arrVal) => {
if (!arrVal || typeof arrVal !== 'object') return arrVal;
- return this.transformObjectKeys(arrVal, idToAliasMap);
+ return transformObjectKeys(arrVal, idToAliasMap);
});
} else if (
value &&
@@ -5455,7 +5457,7 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
!Array.isArray(value)
) {
// Transform non-array objects
- transformedItem[targetKey] = this.transformObjectKeys(
+ transformedItem[targetKey] = transformObjectKeys(
value,
idToAliasMap,
);
@@ -5473,21 +5475,6 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
});
}
- // Helper method to transform object keys using the alias map
- private transformObjectKeys(
- obj: Record<string, any>,
- aliasMap: Record<string, string>,
- ): Record<string, any> {
- if (!obj || typeof obj !== 'object') return obj;
-
- const result = {};
- Object.entries(obj).forEach(([key, value]) => {
- const alias = aliasMap[key];
- result[alias || key] = value;
- });
- return result;
- }
-
protected async convertUserFormat(
data: Record<string, any>,
dependencyColumns?: Column[],
@@ -5668,8 +5655,9 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
}
// Handle array of arrays (lookup case)
- if (Array.isArray(attachment)) {
- for (const lookedUpAttachment of attachment) {
+ for (const lookedUpAttachment of Array.isArray(attachment)
+ ? attachment
+ : [attachment]) {
const thumbnails =
this.prepareAttachmentForSigning(lookedUpAttachment);
if (
@@ -5677,13 +5665,6 @@ class BaseModelSqlv2 implements IBaseModelSqlV2 {
(lookedUpAttachment.path || lookedUpAttachment.url)
) {
allAttachments.push(lookedUpAttachment);
- allThumbnails.push(...thumbnails);
- }
- }
- } else {
- const thumbnails = this.prepareAttachmentForSigning(attachment);
- if (attachment && (attachment.path || attachment.url)) {
- allAttachments.push(attachment);
allThumbnails.push(...thumbnails);
}
}
diff --git a/packages/nocodb/src/helpers/dbHelpers.ts b/packages/nocodb/src/helpers/dbHelpers.ts
index 1ef986de5d..5fd23461e0 100644
--- a/packages/nocodb/src/helpers/dbHelpers.ts
+++ b/packages/nocodb/src/helpers/dbHelpers.ts
@@ -798,3 +798,18 @@ export const dataWrapper = (data: any) => {
},
};
};
+
+// Helper method to transform object keys using the alias map
+export function transformObjectKeys(
+ obj: Record<string, any>,
+ aliasMap: Record<string, string>,
+): Record<string, any> {
+ if (!obj || typeof obj !== 'object') return obj;
+
+ const result = {};
+ Object.entries(obj).forEach(([key, value]) => {
+ const alias = aliasMap[key];
+ result[alias || key] = value;
+ });
+ return result;
+}