diff --git a/packages/nc-gui/composables/useData.ts b/packages/nc-gui/composables/useData.ts index 33f3cfb57b..a287042292 100644 --- a/packages/nc-gui/composables/useData.ts +++ b/packages/nc-gui/composables/useData.ts @@ -559,6 +559,19 @@ export function useData(args: { .map((c) => row.row[c.title!]) .join('___') + const fullRecord = await $api.dbTableRow.read( + NOCO, + // todo: base_id missing on view type + base?.value.id as string, + meta.value?.id as string, + encodeURIComponent(id as string), + { + getHiddenColumn: true, + }, + ) + + row.row = fullRecord + const deleted = await deleteRowById(id as string) if (!deleted) { return @@ -584,6 +597,7 @@ export function useData(args: { pg: { page: number; pageSize: number }, ) { const pkData = rowPkData(row.row, meta.value?.columns as ColumnType[]) + row.row = { ...pkData, ...row.row } await insertRow(row, ltarState, {}, true) recoverLTARRefs(row.row) @@ -642,7 +656,20 @@ export function useData(args: { if (!removedRowsData.length) return + const { list } = await $api.dbTableRow.list(NOCO, base?.value.id as string, meta.value?.id as string, { + pks: removedRowsData.map((row) => row[compositePrimaryKey]).join(','), + }) + try { + for (const removedRow of removedRowsData) { + const rowObj = removedRow.row + const rowPk = rowPkData(rowObj.row, meta?.value?.columns as ColumnType[]) + const fullRecord = list.find((r: Record) => { + return Object.keys(rowPk).every((key) => rowPk[key] === r[key]) + }) + rowObj.row = clone(fullRecord) + } + const removedRowIds: Record[] = await bulkDeleteRows( removedRowsData.map((row) => ({ [compositePrimaryKey]: row[compositePrimaryKey] as string })), ) @@ -767,7 +794,20 @@ export function useData(args: { if (!removedRowsData.length) return + const { list } = await $api.dbTableRow.list(NOCO, base?.value.id as string, meta.value?.id as string, { + pks: removedRowsData.map((row) => row[compositePrimaryKey]).join(','), + }) + try { + for (const removedRow of removedRowsData) { + const rowObj = removedRow.row + const rowPk = rowPkData(rowObj.row, meta?.value?.columns as ColumnType[]) + const fullRecord = list.find((r: Record) => { + return Object.keys(rowPk).every((key) => rowPk[key] === r[key]) + }) + rowObj.row = clone(fullRecord) + } + const removedRowIds: Record[] = await bulkDeleteRows( removedRowsData.map((row) => ({ [compositePrimaryKey]: row[compositePrimaryKey] as string })), ) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 586882ec0c..5fbc87b130 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -426,7 +426,24 @@ class BaseModelSqlv2 { if (createdCol) qb.orderBy(createdCol.column_name); } - if (!ignorePagination) applyPaginate(qb, rest); + if (rest.pks) { + const pks = rest.pks.split(','); + qb.where((qb) => { + pks.forEach((pk) => { + qb.orWhere(_wherePk(this.model.primaryKeys, pk)); + }); + return qb; + }); + } + + // For calendar View, if calendarLimitOverride is provided, use it as limit for the query + if (!ignorePagination) { + if (!calendarLimitOverride) { + applyPaginate(qb, rest); + } else { + applyPaginate(qb, { ...rest, limit: calendarLimitOverride }); + } + } const proto = await this.getProto(); let data; @@ -2114,6 +2131,7 @@ class BaseModelSqlv2 { obj.offset = Math.max(+(args.offset || args.o) || 0, 0); obj.fields = args.fields || args.f; obj.sort = args.sort || args.s; + obj.pks = args.pks; return obj; } @@ -6382,6 +6400,7 @@ export function getListArgs( obj.fields = args?.fields || args?.f || (ignoreAssigningWildcardSelect ? null : '*'); obj.sort = args?.sort || args?.s || model.primaryKey?.[0]?.column_name; + obj.pks = args?.pks; return obj; } diff --git a/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts b/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts index f0a7ccb85b..7eb712b5bb 100644 --- a/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts +++ b/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts @@ -1514,6 +1514,7 @@ export interface XcFilter { fields?: string; filterArr?: Filter[]; sortArr?: Sort[]; + pks?: string; } export interface XcFilterWithAlias extends XcFilter { diff --git a/packages/nocodb/src/schema/swagger-v2.json b/packages/nocodb/src/schema/swagger-v2.json index 47740de402..d83879580b 100644 --- a/packages/nocodb/src/schema/swagger-v2.json +++ b/packages/nocodb/src/schema/swagger-v2.json @@ -7503,6 +7503,14 @@ "in": "query", "name": "filterArrJson", "description": "Used for multiple filter queries" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "pks", + "description": "Comma separated list of pks" } ], "description": "List all shared view rows" diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index 71f2920c9b..35d6be38a9 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -9040,6 +9040,14 @@ "name": "filterArrJson", "description": "Used for multiple filter queries" }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "pks", + "description": "Comma separated list of pks" + }, { "$ref": "#/components/parameters/xc-auth" } @@ -12348,6 +12356,14 @@ "in": "query", "name": "filterArrJson", "description": "Used for multiple filter queries" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "pks", + "description": "Comma separated list of pks" } ], "description": "List all shared view rows" @@ -15914,6 +15930,14 @@ "name": "filterArrJson", "description": "Used for multiple filter queries" }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "pks", + "description": "Comma separated list of pks" + }, { "$ref": "#/components/parameters/xc-auth" }