mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-25 07:45:25 +00:00
fix: handle type diff while comparing pks
This commit is contained in:
@@ -88,6 +88,9 @@ const GROUP_COL = '__nc_group_id';
|
|||||||
|
|
||||||
const nanoidv2 = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 14);
|
const nanoidv2 = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz', 14);
|
||||||
|
|
||||||
|
const isPrimitiveType = (val) =>
|
||||||
|
typeof val === 'string' || typeof val === 'number';
|
||||||
|
|
||||||
export async function populatePk(
|
export async function populatePk(
|
||||||
context: NcContext,
|
context: NcContext,
|
||||||
model: Model,
|
model: Model,
|
||||||
@@ -4830,6 +4833,12 @@ class BaseModelSqlv2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
comparePks(pk1, pk2) {
|
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);
|
return equal(pk1, pk2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user