diff --git a/packages/nc-gui/composables/useColumnCreateStore.ts b/packages/nc-gui/composables/useColumnCreateStore.ts index cfbd1f2b3f..de061e29dc 100644 --- a/packages/nc-gui/composables/useColumnCreateStore.ts +++ b/packages/nc-gui/composables/useColumnCreateStore.ts @@ -286,6 +286,9 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState try { formState.value.table_name = meta.value?.table_name + + const refModelId = formState.value.custom?.ref_model_id + // formState.value.title = formState.value.column_name if (column.value) { // reset column validation if column is not to be validated @@ -339,8 +342,8 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState /** if LTAR column then force reload related table meta */ if (isLinksOrLTAR(formState.value) && meta.value?.id !== formState.value.childId) { - if (formState.value.is_custom_link) { - getMeta(formState.value.custom?.ref_model_id, true).then(() => {}) + if (refModelId) { + getMeta(refModelId, true).then(() => {}) } else { getMeta(formState.value.childId, true).then(() => {}) } diff --git a/packages/nocodb-sdk/src/lib/sqlUi/PgUi.ts b/packages/nocodb-sdk/src/lib/sqlUi/PgUi.ts index c46b8c9757..64367876dd 100644 --- a/packages/nocodb-sdk/src/lib/sqlUi/PgUi.ts +++ b/packages/nocodb-sdk/src/lib/sqlUi/PgUi.ts @@ -2033,7 +2033,7 @@ export class PgUi { } static isEqual(dataType1: string, dataType2: string) { - if (dataType1 === dataType2) return true; + if (dataType1?.toLowerCase() === dataType2?.toLowerCase()) return true; const abstractType1 = this.getAbstractType({ dt: dataType1 }); const abstractType2 = this.getAbstractType({ dt: dataType2 }); diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts index d7444949a2..32c50303d2 100644 --- a/packages/nocodb/src/services/columns.service.ts +++ b/packages/nocodb/src/services/columns.service.ts @@ -2118,8 +2118,8 @@ export class ColumnsService { })?.colOptions as LinkToAnotherRecordColumn; if (!link) { link = await ncMeta.metaGet2( - null, - null, + table.fk_workspace_id, + table.base_id, MetaTable.COL_RELATIONS, {}, null, diff --git a/packages/nocodb/src/services/tables.service.ts b/packages/nocodb/src/services/tables.service.ts index 30a6b32504..b08fc4c3a7 100644 --- a/packages/nocodb/src/services/tables.service.ts +++ b/packages/nocodb/src/services/tables.service.ts @@ -228,8 +228,8 @@ export class TablesService { } else { // if table is using in custom relation as junction table then delete all the relation const relations = await Noco.ncMeta.metaList2( - null, - null, + table.fk_workspace_id, + table.base_id, MetaTable.COL_RELATIONS, { condition: { @@ -239,8 +239,10 @@ export class TablesService { ); if (relations.length) { - const relCol = await Column.get(context, { colId: relations[0].fk_column_id }); - const relTable = await Model.get(context,relCol.fk_model_id); + const relCol = await Column.get(context, { + colId: relations[0].fk_column_id, + }); + const relTable = await Model.get(context, relCol.fk_model_id); NcError.tableAssociatedWithLink(table.id, { customMessage: `This is a many to many table for '${relTable?.title}' (${relTable?.title}), please delete the column before deleting the table.`, }); diff --git a/packages/nocodb/tests/unit/rest/tests/column.test.ts b/packages/nocodb/tests/unit/rest/tests/column.test.ts index 41a0eee6ae..17e8225205 100644 --- a/packages/nocodb/tests/unit/rest/tests/column.test.ts +++ b/packages/nocodb/tests/unit/rest/tests/column.test.ts @@ -52,7 +52,9 @@ function columnTests() { ], }); - const pkColumn = (await country.getColumns(context)).find((column) => column.pk); + const pkColumn = (await country.getColumns(context)).find( + (column) => column.pk, + ); const fkColumn = (await city.getColumns(context)).find( (column) => column.title === 'CountryId', ); @@ -175,8 +177,12 @@ function columnTests() { ], }); - const pkColumn = (await actor.getColumns(context)).find((column) => column.pk); - const refPkColumn = (await film.getColumns(context)).find((column) => column.pk); + const pkColumn = (await actor.getColumns(context)).find( + (column) => column.pk, + ); + const refPkColumn = (await film.getColumns(context)).find( + (column) => column.pk, + ); const junColId = (await filmActor.getColumns(context)).find( (column) => column.title === 'ActorId', );