Browse Source

fix: avoid deleting foreign key when it's a custom link

pull/8367/head
Pranav C 4 months ago
parent
commit
f3381252ff
  1. 19
      packages/nc-gui/components/smartsheet/column/LinkAdvancedOptions.vue
  2. 14
      packages/nocodb/src/helpers/columnHelpers.ts

19
packages/nc-gui/components/smartsheet/column/LinkAdvancedOptions.vue

@ -1,6 +1,13 @@
<script setup lang="ts">
import { useColumnCreateStoreOrThrow, useVModel, computed, inject, MetaInj, ref, useI18n,useBase, storeToRefs, useMetas } from '#imports'
import {isVirtualCol, ModelTypes, RelationTypes, UITypes} from "nocodb-sdk";
import {
isCreatedOrLastModifiedByCol,
isCreatedOrLastModifiedTimeCol,
isVirtualCol,
ModelTypes,
RelationTypes,
UITypes
} from "nocodb-sdk";
import type {ColumnType} from "nocodb-sdk";
const props = defineProps<{
@ -46,7 +53,7 @@ const columns = computed(() => {
return []
}
return meta.value.columns;
return meta.value.columns?.filter(c => !isCreatedOrLastModifiedByCol(c) && !isCreatedOrLastModifiedTimeCol(c) && !isVirtualCol(c));
})
const refTableColumns = computed(() => {
@ -55,9 +62,7 @@ const refTableColumns = computed(() => {
}
return metas.value[vModel.value.custom?.ref_model_id]?.columns.filter(
(c: ColumnType) => !isVirtualCol(c.uidt as UITypes),
)
return metas.value[vModel.value.custom?.ref_model_id]?.columns?.filter(c => !isCreatedOrLastModifiedByCol(c) && !isCreatedOrLastModifiedTimeCol(c) && !isVirtualCol(c))
})
const juncTableColumns = computed(() => {
@ -66,9 +71,7 @@ const juncTableColumns = computed(() => {
}
return metas.value[vModel.value.custom?.junc_model_id]?.columns.filter(
(c: ColumnType) => !isVirtualCol(c.uidt as UITypes),
)
return metas.value[vModel.value.custom?.junc_model_id]?.columns?.filter(c => !isCreatedOrLastModifiedByCol(c) && !isCreatedOrLastModifiedTimeCol(c) && !isVirtualCol(c))
})

14
packages/nocodb/src/helpers/columnHelpers.ts

@ -44,7 +44,7 @@ export async function createHmAndBtColumn(
isLinks = false,
colExtra?: any,
parentColumn?: Column,
isCustom = false
isCustom = false,
) {
// save bt column
{
@ -72,8 +72,8 @@ export async function createHmAndBtColumn(
...(type === 'bt' ? colExtra : {}),
meta: {
...(colExtra?.meta || {}),
custom: isCustom
}
custom: isCustom,
},
});
}
// save hm column
@ -86,7 +86,7 @@ export async function createHmAndBtColumn(
...(columnMeta || {}),
plural: columnMeta?.plural || pluralize(child.title),
singular: columnMeta?.singular || singularize(child.title),
custom: isCustom
custom: isCustom,
};
await Column.insert(context, {
@ -136,7 +136,7 @@ export async function createOOColumn(
columnMeta = null,
colExtra?: any,
parentColumn?: Column,
isCustom = false
isCustom = false,
) {
// save bt column
{
@ -166,7 +166,7 @@ export async function createOOColumn(
// one-to-one relation is combination of both hm and bt to identify table which have
// foreign key column(similar to bt) we are adding a boolean flag `bt` under meta
bt: true,
custom: isCustom
custom: isCustom,
},
});
}
@ -186,7 +186,7 @@ export async function createOOColumn(
...(columnMeta || {}),
plural: columnMeta?.plural || pluralize(child.title),
singular: columnMeta?.singular || singularize(child.title),
custom: isCustom
custom: isCustom,
};
await Column.insert(context, {

Loading…
Cancel
Save