Browse Source

fix: missing pk handling (#8749)

* fix: handle null case

* fix: missing required field
pull/8751/head
Mert E 5 months ago committed by GitHub
parent
commit
486c29bdd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 4
      packages/nocodb/src/helpers/catchError.ts

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

@ -7504,10 +7504,11 @@ export function _wherePk(
} }
export function getCompositePkValue(primaryKeys: Column[], row) { export function getCompositePkValue(primaryKeys: Column[], row) {
if (typeof row !== 'object') return row; if (row === null || row === undefined) {
if (row === null)
NcError.requiredFieldMissing(primaryKeys.map((c) => c.title).join(',')); NcError.requiredFieldMissing(primaryKeys.map((c) => c.title).join(','));
}
if (typeof row !== 'object') return row;
return primaryKeys.map((c) => row[c.title] ?? row[c.column_name]).join('___'); return primaryKeys.map((c) => row[c.title] ?? row[c.column_name]).join('___');
} }

4
packages/nocodb/src/helpers/catchError.ts

@ -670,7 +670,9 @@ export class NcError {
id: string | string[] | Record<string, string> | Record<string, string>[], id: string | string[] | Record<string, string> | Record<string, string>[],
args?: NcErrorArgs, args?: NcErrorArgs,
) { ) {
if (typeof id === 'string') { if (!id) {
id = 'unknown';
} else if (typeof id === 'string') {
id = [id]; id = [id];
} else if (Array.isArray(id)) { } else if (Array.isArray(id)) {
if (id.every((i) => typeof i === 'string')) { if (id.every((i) => typeof i === 'string')) {

Loading…
Cancel
Save