Browse Source

fix: falsy value id handling in update api

pull/9348/head
Pranav C 3 months ago
parent
commit
bbaec26544
  1. 2
      packages/nocodb-sdk/src/lib/globals.ts
  2. 4
      packages/nocodb/src/db/BaseModelSqlv2.ts
  3. 8
      packages/nocodb/src/helpers/catchError.ts

2
packages/nocodb-sdk/src/lib/globals.ts

@ -195,6 +195,8 @@ export enum NcErrorType {
TABLE_ASSOCIATED_WITH_LINK = 'TABLE_ASSOCIATED_WITH_LINK', TABLE_ASSOCIATED_WITH_LINK = 'TABLE_ASSOCIATED_WITH_LINK',
INTEGRATION_NOT_FOUND = 'INTEGRATION_NOT_FOUND', INTEGRATION_NOT_FOUND = 'INTEGRATION_NOT_FOUND',
INTEGRATION_LINKED_WITH_BASES = 'INTEGRATION_LINKED_WITH_BASES', INTEGRATION_LINKED_WITH_BASES = 'INTEGRATION_LINKED_WITH_BASES',
FORMULA_ERROR = 'FORMULA_ERROR',
PERMISSION_DENIED = 'PERMISSION_DENIED',
} }
type Roles = OrgUserRoles | ProjectRoles | WorkspaceUserRoles; type Roles = OrgUserRoles | ProjectRoles | WorkspaceUserRoles;

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

@ -5745,7 +5745,7 @@ class BaseModelSqlv2 {
await this.prepareNocoData(updateData, false, cookie); await this.prepareNocoData(updateData, false, cookie);
const pkValues = this.extractPksValues(updateData); const pkValues = this.extractPksValues(updateData);
if (pkValues) { if (pkValues !== null && pkValues !== undefined) {
// pk is specified - by pass // pk is specified - by pass
} else { } else {
const { where } = this._getListArgs(args); const { where } = this._getListArgs(args);
@ -6467,7 +6467,7 @@ class BaseModelSqlv2 {
if (this.model.primaryKeys.length > 1) { if (this.model.primaryKeys.length > 1) {
const pkValues = {}; const pkValues = {};
for (const pk of this.model.primaryKeys) { for (const pk of this.model.primaryKeys) {
pkValues[pk.title] = data[pk.title] || data[pk.column_name]; pkValues[pk.title] = data[pk.title] ?? data[pk.column_name];
} }
return pkValues; return pkValues;
} else if (this.model.primaryKey) { } else if (this.model.primaryKey) {

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

@ -580,6 +580,14 @@ const errorHelpers: {
message: 'Table is associated with a link, please remove the link first', message: 'Table is associated with a link, please remove the link first',
code: 400, code: 400,
}, },
[NcErrorType.FORMULA_ERROR]: {
message: (message: string) => `Formula error: ${message}`,
code: 400,
},
[NcErrorType.PERMISSION_DENIED]: {
message: 'Permission denied',
code: 403,
},
}; };
function generateError( function generateError(

Loading…
Cancel
Save