Browse Source

fix: pass proper context

pull/8367/head
Pranav C 5 months ago
parent
commit
6759a2a8c5
  1. 7
      packages/nc-gui/composables/useColumnCreateStore.ts
  2. 2
      packages/nocodb-sdk/src/lib/sqlUi/PgUi.ts
  3. 4
      packages/nocodb/src/services/columns.service.ts
  4. 10
      packages/nocodb/src/services/tables.service.ts
  5. 12
      packages/nocodb/tests/unit/rest/tests/column.test.ts

7
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(() => {})
}

2
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 });

4
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,

10
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.`,
});

12
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',
);

Loading…
Cancel
Save