Browse Source

fix: keep single display value per model

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5141/head
mertmit 2 years ago
parent
commit
500c017d75
  1. 8
      packages/nocodb/src/lib/models/Model.ts

8
packages/nocodb/src/lib/models/Model.ts

@ -561,14 +561,14 @@ export default class Model implements TableType {
ncMeta = Noco.ncMeta ncMeta = Noco.ncMeta
) { ) {
const model = await this.getWithInfo({ id: tableId }); const model = await this.getWithInfo({ id: tableId });
const currentPvCol = model.displayValue;
const newPvCol = model.columns.find((c) => c.id === columnId); const newPvCol = model.columns.find((c) => c.id === columnId);
if (!newPvCol) NcError.badRequest('Column not found'); if (!newPvCol) NcError.badRequest('Column not found');
if (currentPvCol) { // drop existing primary column/s
for (const col of model.columns?.filter((c) => c.pv) || []) {
// get existing cache // get existing cache
const key = `${CacheScope.COLUMN}:${currentPvCol.id}`; const key = `${CacheScope.COLUMN}:${col.id}`;
const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
if (o) { if (o) {
o.pv = false; o.pv = false;
@ -583,7 +583,7 @@ export default class Model implements TableType {
{ {
pv: false, pv: false,
}, },
currentPvCol.id col.id
); );
} }

Loading…
Cancel
Save