Skip to content

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

fix: BT reverse column should use LinkToAnotherRecord, fix version heuristic

Pranave645d16c0a78
diff --git a/packages/nocodb/src/models/Column.ts b/packages/nocodb/src/models/Column.ts
index 71660a9456..a9101b0678 100644
--- a/packages/nocodb/src/models/Column.ts
+++ b/packages/nocodb/src/models/Column.ts
@@ -343,13 +343,14 @@ export default class Column<T = any> implements ColumnType {
}
case UITypes.Links:
case UITypes.LinkToAnotherRecord: {
- // V1 for hm/bt or oo without junction table (always V1, not overridable)
- // For other types, use caller-provided version or default to V2
+ // V1 for hm/bt/oo without junction table (always V1, not overridable)
+ // If junction table exists (fk_mm_model_id), use caller version or default V2
const isV1Heuristic =
- [RelationTypes.HAS_MANY, RelationTypes.BELONGS_TO].includes(
+ !column.fk_mm_model_id &&
+ ([RelationTypes.HAS_MANY, RelationTypes.BELONGS_TO].includes(
column.type,
) ||
- (column.type === RelationTypes.ONE_TO_ONE && !column.fk_mm_model_id);
+ column.type === RelationTypes.ONE_TO_ONE);
const version: number = isV1Heuristic
? LinksVersion.V1
diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts
index d181876383..c51cfdfd6f 100644
--- a/packages/nocodb/src/services/columns.service.ts
+++ b/packages/nocodb/src/services/columns.service.ts
@@ -5141,7 +5141,14 @@ export class ColumnsService implements IColumnsService {
],
reverseDefaultTitle,
),
- uidt: isLinks ? UITypes.Links : UITypes.LinkToAnotherRecord,
+ // BT reverse column should always be LinkToAnotherRecord (not Links)
+ // to match V1 behavior where BT doesn't show count/rollup
+ uidt:
+ revType === RelationTypes.BELONGS_TO
+ ? UITypes.LinkToAnotherRecord
+ : isLinks
+ ? UITypes.Links
+ : UITypes.LinkToAnotherRecord,
type: revType,
version: isMMLike ? 2 : 1,