Browse Source

fix: comparing composite pks

pull/8315/head
mertmit 7 months ago
parent
commit
f4bbf64109
  1. 13
      packages/nocodb/src/db/BaseModelSqlv2.ts

13
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -4,6 +4,7 @@ import DataLoader from 'dataloader';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc.js'; import utc from 'dayjs/plugin/utc.js';
import timezone from 'dayjs/plugin/timezone'; import timezone from 'dayjs/plugin/timezone';
import equal from 'fast-deep-equal';
import { nocoExecute } from 'nc-help'; import { nocoExecute } from 'nc-help';
import { import {
AuditOperationSubTypes, AuditOperationSubTypes,
@ -3007,6 +3008,10 @@ class BaseModelSqlv2 {
return _wherePk(this.model.primaryKeys, id); return _wherePk(this.model.primaryKeys, id);
} }
comparePks(pk1, pk2) {
return equal(pk1, pk2);
}
public getTnPath(tb: { table_name: string } | string, alias?: string) { public getTnPath(tb: { table_name: string } | string, alias?: string) {
const tn = typeof tb === 'string' ? tb : tb.table_name; const tn = typeof tb === 'string' ? tb : tb.table_name;
const schema = (this.dbDriver as any).searchPath?.(); const schema = (this.dbDriver as any).searchPath?.();
@ -3757,8 +3762,8 @@ class BaseModelSqlv2 {
prevData.push(...oldRecords); prevData.push(...oldRecords);
} else { } else {
for (const recordPk of tempToRead) { for (const recordPk of tempToRead) {
const oldRecord = oldRecords.find( const oldRecord = oldRecords.find((r) =>
(r) => this._extractPksValues(r) === recordPk, this.comparePks(this._extractPksValues(r), recordPk),
); );
if (!oldRecord) { if (!oldRecord) {
@ -3976,8 +3981,8 @@ class BaseModelSqlv2 {
res.push(...tempToRead.map((v) => v.data)); res.push(...tempToRead.map((v) => v.data));
} else { } else {
for (const { pk, data } of tempToRead) { for (const { pk, data } of tempToRead) {
const oldRecord = oldRecords.find( const oldRecord = oldRecords.find((r) =>
(r) => this._extractPksValues(r) === pk, this.comparePks(this._extractPksValues(r), pk),
); );
if (!oldRecord) { if (!oldRecord) {

Loading…
Cancel
Save