Skip to content

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

fix: retain uidt if campatable with nw type

Pranav C64fa7616bddc
diff --git a/packages/nocodb/src/services/meta-diffs.service.ts b/packages/nocodb/src/services/meta-diffs.service.ts
index 0f36966d12..16bfa8793c 100644
--- a/packages/nocodb/src/services/meta-diffs.service.ts
+++ b/packages/nocodb/src/services/meta-diffs.service.ts
@@ -1,11 +1,13 @@
import { Injectable } from '@nestjs/common';
import {
AppEvents,
+ ClientType,
isAIPromptCol,
isLinksOrLTAR,
isVirtualCol,
ModelTypes,
RelationTypes,
+ SqlUiFactory,
UITypes,
} from 'nocodb-sdk';
import { pluralize, singularize } from 'inflection';
@@ -711,6 +713,7 @@ export class MetaDiffsService {
// @ts-ignore
const sqlClient = await NcConnectionMgrv2.getSqlClient(source);
+ const sqlUi = SqlUiFactory.create({ client: source.type ?? ClientType.PG });
const changes = await this.getMetaDiff(context, sqlClient, base, source);
/* Get all relations */
@@ -839,7 +842,17 @@ export class MetaDiffsService {
{ client: source.type },
{},
);
- column.uidt = metaFact.getUIDataType(column);
+
+ // check if new type is compatible with old uidt
+ const allowedDatatypes = sqlUi.getDataTypeListForUiType(
+ column.uidt,
+ );
+
+ // if UIDT not compatible with new type then change uidt
+ if (!allowedDatatypes?.includes(column.dt)) {
+ column.uidt = metaFact.getUIDataType(column);
+ }
+
column.title = change.column.title;
await Column.update(context, change.column.id, column);
}