Browse Source

Merge pull request #9494 from nocodb/nc-fix/compare-pks

fix: handle type diff while comparing pks
pull/9519/head
Pranav C 2 months ago committed by GitHub
parent
commit
a3409c6c66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      packages/nocodb/src/db/BaseModelSqlv2.ts

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

@ -88,6 +88,9 @@ const GROUP_COL = '__nc_group_id';
const nanoidv2 = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 14);
const isPrimitiveType = (val) =>
typeof val === 'string' || typeof val === 'number';
export async function populatePk(
context: NcContext,
model: Model,
@ -4839,6 +4842,12 @@ class BaseModelSqlv2 {
}
comparePks(pk1, pk2) {
// If either pk1 or pk2 is a string or number, convert both to strings and compare
if (isPrimitiveType(pk1) || isPrimitiveType(pk2)) {
return `${pk1}` === `${pk2}`;
}
// If both are objects (composite keys), compare them using deep equality check
return equal(pk1, pk2);
}

Loading…
Cancel
Save