diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue index 57ce30e2fd..79195050b3 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue @@ -112,9 +112,7 @@ const hiddenFields = computed(() => { .filter( (col) => !fields.value?.includes(col) && - (isLocalMode.value && col?.id && fieldsMap.value[col.id] - ? fieldsMap.value[col.id]?.initialShow - : true), + (isLocalMode.value && col?.id && fieldsMap.value[col.id] ? fieldsMap.value[col.id]?.initialShow : true), ) .filter((col) => !isSystemColumn(col)) }) diff --git a/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts b/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts index dd609b9635..6714d14807 100644 --- a/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts +++ b/packages/nc-gui/components/smartsheet/grid/useColumnDrag.ts @@ -109,7 +109,7 @@ export const useColumnDrag = ({ const handleReorderColumn = async () => { isProcessing.value = true try { - if (!dragColPlaceholderDomRef.value) return + if (!dragColPlaceholderDomRef.value) return dragColPlaceholderDomRef.value!.style.left = '0px' dragColPlaceholderDomRef.value!.style.height = '0px' diff --git a/packages/nc-gui/components/smartsheet/header/Menu.vue b/packages/nc-gui/components/smartsheet/header/Menu.vue index 0bc6c8ce43..5749ec8609 100644 --- a/packages/nc-gui/components/smartsheet/header/Menu.vue +++ b/packages/nc-gui/components/smartsheet/header/Menu.vue @@ -328,8 +328,8 @@ const isDuplicateAllowed = computed(() => { return ( column?.value && !column.value.system && - ((!isMetaReadOnly.value && !isDataReadOnly.value) || readonlyMetaAllowedTypes.includes(column.value?.uidt)) - && !column.value.meta?.custom + ((!isMetaReadOnly.value && !isDataReadOnly.value) || readonlyMetaAllowedTypes.includes(column.value?.uidt)) && + !column.value.meta?.custom ) }) const isFilterSupported = computed( diff --git a/packages/nc-gui/composables/useExpandedFormStore.ts b/packages/nc-gui/composables/useExpandedFormStore.ts index 32724a37f0..12704c4377 100644 --- a/packages/nc-gui/composables/useExpandedFormStore.ts +++ b/packages/nc-gui/composables/useExpandedFormStore.ts @@ -331,7 +331,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m if (missingRequiredColumns.size) return - data = await $api.dbTableRow.create('noco', meta.value.base_id, meta.value.id, { + data = await $api.dbTableRow.create('noco', meta.value.base_id, meta.value.id, { ...insertObj, ...(ltarState || {}), }) diff --git a/packages/nc-gui/composables/useViewColumns.ts b/packages/nc-gui/composables/useViewColumns.ts index c257b1b0e6..75c40af61f 100644 --- a/packages/nc-gui/composables/useViewColumns.ts +++ b/packages/nc-gui/composables/useViewColumns.ts @@ -136,7 +136,7 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState( if (isLocalMode.value) { const fieldById = (fields.value || []).reduce>((acc, curr) => { if (curr.fk_column_id) { - curr.show = curr.initialShow ? true : false + curr.show = !!curr.initialShow acc[curr.fk_column_id] = curr } return acc diff --git a/packages/nc-gui/store/sidebar.ts b/packages/nc-gui/store/sidebar.ts index 926888a84f..f8e51cfb5e 100644 --- a/packages/nc-gui/store/sidebar.ts +++ b/packages/nc-gui/store/sidebar.ts @@ -1,5 +1,5 @@ import { acceptHMRUpdate, defineStore } from 'pinia' -import { MAX_WIDTH_FOR_MOBILE_MODE, INITIAL_LEFT_SIDEBAR_WIDTH } from '~/lib/constants' +import { INITIAL_LEFT_SIDEBAR_WIDTH, MAX_WIDTH_FOR_MOBILE_MODE } from '~/lib/constants' export const useSidebarStore = defineStore('sidebarStore', () => { const { width } = useWindowSize() diff --git a/packages/nocodb/src/controllers/notifications.controller.ts b/packages/nocodb/src/controllers/notifications.controller.ts index 446be008e4..d3a423d5de 100644 --- a/packages/nocodb/src/controllers/notifications.controller.ts +++ b/packages/nocodb/src/controllers/notifications.controller.ts @@ -45,7 +45,8 @@ export class NotificationsController { this.notificationsService.addConnection(req.user.id, res); - let unsubscribeCallback: (keepRedisChannel?: boolean) => Promise = null; + let unsubscribeCallback: (keepRedisChannel?: boolean) => Promise = + null; if (PubSubRedis.available) { unsubscribeCallback = await PubSubRedis.subscribe( @@ -57,7 +58,11 @@ export class NotificationsController { } res.on('close', async () => { - await this.notificationsService.removeConnection(req.user.id, res, unsubscribeCallback); + await this.notificationsService.removeConnection( + req.user.id, + res, + unsubscribeCallback, + ); }); setTimeout(() => { diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 8effffb245..ec25245f6d 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -2015,7 +2015,7 @@ class BaseModelSqlv2 { ).orWhereNull(rcn); }); - const aliasColObjMap = await childTable.getAliasColObjMap(this.context); + const aliasColObjMap = await childTable.getAliasColObjMap(this.context); const filterObj = extractFilterFromXwhere(where, aliasColObjMap); await this.getCustomConditionsAndApply({ @@ -2199,8 +2199,12 @@ class BaseModelSqlv2 { const rcn = (await relColOptions.getParentColumn(this.context)).column_name; const cn = (await relColOptions.getChildColumn(this.context)).column_name; - const childTable = await (await relColOptions.getParentColumn(this.cotext)).getModel(this.cotext); - const parentTable = await (await relColOptions.getChildColumn(this.cotext)).getModel(this.cotext); + const childTable = await ( + await relColOptions.getParentColumn(this.cotext) + ).getModel(this.cotext); + const parentTable = await ( + await relColOptions.getChildColumn(this.cotext) + ).getModel(this.cotext); await parentTable.getColumns(); const parentBaseModel = await Model.getBaseModelSQL({ id: parentTable.id, @@ -5881,7 +5885,7 @@ class BaseModelSqlv2 { await triggerAfterRemoveChild(); await this.updateLastModified({ - baseModel: parentBaseModel, + baseModel: parentBaseModel, model: parentTable, rowIds: [childId], cookie, diff --git a/packages/nocodb/src/db/genRollupSelectv2.ts b/packages/nocodb/src/db/genRollupSelectv2.ts index 697d4f6815..dca5609f8f 100644 --- a/packages/nocodb/src/db/genRollupSelectv2.ts +++ b/packages/nocodb/src/db/genRollupSelectv2.ts @@ -47,7 +47,7 @@ export default async function ({ case RelationTypes.HAS_MANY: { const queryBuilder: any = knex( knex.raw(`?? as ??`, [ - childBaseModel.getTnPath(childModel), + childBaseModel.getTnPath(childModel), refTableAlias, ]), ) @@ -56,7 +56,7 @@ export default async function ({ ) .where( knex.ref( - `${alias || parentBaseModel.getTnPath(parentModel.table_name)}.${ + `${alias || parentBaseModel.getTnPath(parentModel.table_name)}.${ parentCol.column_name }`, ), @@ -72,7 +72,7 @@ export default async function ({ case RelationTypes.ONE_TO_ONE: { const qb = knex( knex.raw(`?? as ??`, [ - childBaseModel.getTnPath(childModel?.table_name), + childBaseModel.getTnPath(childModel?.table_name), refTableAlias, ]), ) @@ -81,7 +81,7 @@ export default async function ({ ) .where( knex.ref( - `${alias || parentBaseModel.getTnPath(parentModel.table_name)}.${ + `${alias || parentBaseModel.getTnPath(parentModel.table_name)}.${ parentCol.column_name }`, ), @@ -110,7 +110,7 @@ export default async function ({ const qb = knex( knex.raw(`?? as ??`, [ - parentBaseModel.getTnPath(parentModel?.table_name), + parentBaseModel.getTnPath(parentModel?.table_name), refTableAlias, ]), ) @@ -118,9 +118,9 @@ export default async function ({ knex.ref(`${refTableAlias}.${rollupColumn.column_name}`), ) .innerJoin( - assocBaseModel.getTnPath(mmModel.table_name), + assocBaseModel.getTnPath(mmModel.table_name), knex.ref( - `${assocBaseModel.getTnPath(mmModel.table_name)}.${ + `${assocBaseModel.getTnPath(mmModel.table_name)}.${ mmParentCol.column_name }`, ), @@ -129,13 +129,13 @@ export default async function ({ ) .where( knex.ref( - `${assocBaseModel.getTnPath(mmModel.table_name)}.${ + `${assocBaseModel.getTnPath(mmModel.table_name)}.${ mmChildCol.column_name }`, ), '=', knex.ref( - `${alias || childBaseModel.getTnPath(childModel.table_name)}.${ + `${alias || childBaseModel.getTnPath(childModel.table_name)}.${ childCol.column_name }`, ), diff --git a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts index e011cff638..ac014a0491 100644 --- a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts +++ b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts @@ -15,6 +15,7 @@ import FetchAT from './helpers/fetchAT'; import { importData } from './helpers/readAndProcessData'; import EntityMap from './helpers/EntityMap'; import type { UserType } from 'nocodb-sdk'; +import type { AtImportJobData } from '~/interface/Jobs'; import { type Base, Model, Source } from '~/models'; import { sanitizeColumnName } from '~/helpers'; import { AttachmentsService } from '~/services/attachments.service'; @@ -31,7 +32,7 @@ import { TablesService } from '~/services/tables.service'; import { ViewColumnsService } from '~/services/view-columns.service'; import { ViewsService } from '~/services/views.service'; import { FormsService } from '~/services/forms.service'; -import { AtImportJobData, JOBS_QUEUE, JobTypes } from '~/interface/Jobs'; +import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs'; import { GridColumnsService } from '~/services/grid-columns.service'; import { TelemetryService } from '~/services/telemetry.service'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; diff --git a/packages/nocodb/src/redis/pubsub-redis.ts b/packages/nocodb/src/redis/pubsub-redis.ts index dd699afa63..d9e10a1dd5 100644 --- a/packages/nocodb/src/redis/pubsub-redis.ts +++ b/packages/nocodb/src/redis/pubsub-redis.ts @@ -42,9 +42,9 @@ export class PubSubRedis { } /** - * - * @param channel - * @param callback + * + * @param channel + * @param callback * @returns Returns a callback to unsubscribe */ static async subscribe( @@ -74,7 +74,8 @@ export class PubSubRedis { PubSubRedis.redisSubscriber.on('message', onMessage); return async (keepRedisChannel = false) => { // keepRedisChannel is used to keep the channel open for other subscribers - if (!keepRedisChannel) await PubSubRedis.redisSubscriber.unsubscribe(channel); + if (!keepRedisChannel) + await PubSubRedis.redisSubscriber.unsubscribe(channel); PubSubRedis.redisSubscriber.off('message', onMessage); }; } diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts index 4a80122533..9c1b486926 100644 --- a/packages/nocodb/src/services/columns.service.ts +++ b/packages/nocodb/src/services/columns.service.ts @@ -6,7 +6,7 @@ import { isCreatedOrLastModifiedTimeCol, isLinksOrLTAR, isVirtualCol, - partialUpdateAllowedTypes, + partialUpdateAllowedTypes, readonlyMetaAllowedTypes, RelationTypes, substituteColumnAliasWithIdInFormula, @@ -2277,37 +2277,37 @@ export class ColumnsService { ); if (!custom) { - await this.deleteHmOrBtRelation( - context, - { - relationColOpt: null, - parentColumn: parentColumn, - childTable: mmTable, - sqlMgr, - parentTable: parentTable, - childColumn: mmParentCol, - source, - ncMeta, - virtual: !!relationColOpt.virtual, - }, - true, - ); + await this.deleteHmOrBtRelation( + context, + { + relationColOpt: null, + parentColumn: parentColumn, + childTable: mmTable, + sqlMgr, + parentTable: parentTable, + childColumn: mmParentCol, + source, + ncMeta, + virtual: !!relationColOpt.virtual, + }, + true, + ); - await this.deleteHmOrBtRelation( - context, - { - relationColOpt: null, - parentColumn: childColumn, - childTable: mmTable, - sqlMgr, - parentTable: childTable, - childColumn: mmChildCol, - source, - ncMeta, - virtual: !!relationColOpt.virtual, - }, - true, - ); + await this.deleteHmOrBtRelation( + context, + { + relationColOpt: null, + parentColumn: childColumn, + childTable: mmTable, + sqlMgr, + parentTable: childTable, + childColumn: mmChildCol, + source, + ncMeta, + virtual: !!relationColOpt.virtual, + }, + true, + ); } const columnsInRelatedTable: Column[] = await relationColOpt .getRelatedTable(context, ncMeta) @@ -2344,66 +2344,68 @@ export class ColumnsService { if (!custom) { if (mmTable) { // delete bt columns in m2m table - await mmTable.getColumns(context, ncMeta); - for (const c of mmTable.columns) { + await mmTable.getColumns(context, ncMeta); + for (const c of mmTable.columns) { + if (!isLinksOrLTAR(c.uidt)) continue; + const colOpt = + await c.getColOptions( + context, + ncMeta, + ); + if (colOpt.type === 'bt') { + await Column.delete(context, c.id, ncMeta); + } + } + } + + // delete hm columns in parent table + await parentTable.getColumns(context, ncMeta); + for (const c of parentTable.columns) { if (!isLinksOrLTAR(c.uidt)) continue; const colOpt = await c.getColOptions( context, ncMeta, ); - if (colOpt.type === 'bt') { + if ( + colOpt.fk_related_model_id === + relationColOpt.fk_mm_model_id + ) { await Column.delete(context, c.id, ncMeta); } } - } - - // delete hm columns in parent table - await parentTable.getColumns(context, ncMeta); - for (const c of parentTable.columns) { - if (!isLinksOrLTAR(c.uidt)) continue; - const colOpt = - await c.getColOptions( - context, - ncMeta, - ); - if ( - colOpt.fk_related_model_id === relationColOpt.fk_mm_model_id - ) { - await Column.delete(context, c.id, ncMeta); - } - } - // delete hm columns in child table - await childTable.getColumns(context, ncMeta); - for (const c of childTable.columns) { - if (!isLinksOrLTAR(c.uidt)) continue; - const colOpt = - await c.getColOptions( - context, - ncMeta, - ); - if ( - colOpt.fk_related_model_id === relationColOpt.fk_mm_model_id - ) { - await Column.delete(context, c.id, ncMeta); + // delete hm columns in child table + await childTable.getColumns(context, ncMeta); + for (const c of childTable.columns) { + if (!isLinksOrLTAR(c.uidt)) continue; + const colOpt = + await c.getColOptions( + context, + ncMeta, + ); + if ( + colOpt.fk_related_model_id === + relationColOpt.fk_mm_model_id + ) { + await Column.delete(context, c.id, ncMeta); + } } - } - - if (mmTable) { - // retrieve columns in m2m table again - await mmTable.getColumns(context, ncMeta); - // ignore deleting table if it has more than 2 columns - // the expected 2 columns would be table1_id & table2_id - if (mmTable.columns.length === 2) { - (mmTable as any).tn = mmTable.table_name; - await sqlMgr.sqlOpPlus(source, 'tableDelete', mmTable); - await mmTable.delete(context, ncMeta); + if (mmTable) { + // retrieve columns in m2m table again + await mmTable.getColumns(context, ncMeta); + + // ignore deleting table if it has more than 2 columns + // the expected 2 columns would be table1_id & table2_id + if (mmTable.columns.length === 2) { + (mmTable as any).tn = mmTable.table_name; + await sqlMgr.sqlOpPlus(source, 'tableDelete', mmTable); + await mmTable.delete(context, ncMeta); + } } } } - } break; } } @@ -2533,8 +2535,10 @@ export class ColumnsService { for (const col of cols) { if (col.uidt === UITypes.LinkToAnotherRecord) { const colOptions = - await col.getColOptions(context, - ncMeta); + await col.getColOptions( + context, + ncMeta, + ); if (colOptions.fk_related_model_id === parentTable.id) { return { colOptions }; } @@ -2679,48 +2683,50 @@ export class ColumnsService { if (!custom) { let foreignKeyName; - // if relationColOpt is not provided, extract it from child table - // and get the foreign key name for dropping the foreign key - if (!relationColOpt) { - foreignKeyName = ( - ( - await childTable.getColumns(context, ncMeta).then(async (cols) => { - for (const col of cols) { - if (col.uidt === UITypes.LinkToAnotherRecord) { - const colOptions = - await col.getColOptions( - context, - ncMeta, - ); - if (colOptions.fk_related_model_id === parentTable.id) { - return { colOptions }; + // if relationColOpt is not provided, extract it from child table + // and get the foreign key name for dropping the foreign key + if (!relationColOpt) { + foreignKeyName = ( + ( + await childTable + .getColumns(context, ncMeta) + .then(async (cols) => { + for (const col of cols) { + if (col.uidt === UITypes.LinkToAnotherRecord) { + const colOptions = + await col.getColOptions( + context, + ncMeta, + ); + if (colOptions.fk_related_model_id === parentTable.id) { + return { colOptions }; + } + } } - } - } - }) - )?.colOptions as LinkToAnotherRecordType - ).fk_index_name; - } else { - foreignKeyName = relationColOpt.fk_index_name; - } + }) + )?.colOptions as LinkToAnotherRecordType + ).fk_index_name; + } else { + foreignKeyName = relationColOpt.fk_index_name; + } - if (!relationColOpt?.virtual && !virtual) { - // Ensure relation deletion is not attempted for virtual relations - try { - // Attempt to delete the foreign key constraint from the database - await sqlMgr.sqlOpPlus(source, 'relationDelete', { - childColumn: childColumn.column_name, - childTable: childTable.table_name, - parentTable: parentTable.table_name, - parentColumn: parentColumn.column_name, - foreignKeyName, - }); - } catch (e) { - console.log(e.message); + if (!relationColOpt?.virtual && !virtual) { + // Ensure relation deletion is not attempted for virtual relations + try { + // Attempt to delete the foreign key constraint from the database + await sqlMgr.sqlOpPlus(source, 'relationDelete', { + childColumn: childColumn.column_name, + childTable: childTable.table_name, + parentTable: parentTable.table_name, + parentColumn: parentColumn.column_name, + foreignKeyName, + }); + } catch (e) { + console.log(e.message); + } } } } - } if (!relationColOpt) return; const columnsInRelatedTable: Column[] = await relationColOpt @@ -2816,7 +2822,8 @@ export class ColumnsService { base: Base; reuse?: ReusableParams; colExtra?: any; - }) { + }, + ) { validateParams(['parentId', 'childId', 'type'], param.column); const reuse = param.reuse ?? {};