π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
column update not required type
Fendy Heryanto352138d0a1d7
diff --git a/packages/nocodb/src/schema/swagger-v3.json b/packages/nocodb/src/schema/swagger-v3.jsonindex 3f6152a3cb..c1bcae1de9 100644--- a/packages/nocodb/src/schema/swagger-v3.json+++ b/packages/nocodb/src/schema/swagger-v3.json@@ -4745,7 +4745,7 @@"CreateField": {"allOf": [{- "$ref": "#/components/schemas/FieldBase"+ "$ref": "#/components/schemas/FieldBaseCreate"},{"oneOf": [@@ -5634,8 +5634,19 @@}},"required": [- "title",- "type"+ "title"+ ]+ },+ "FieldBaseCreate": {+ "allOf": [+ {+ "$ref": "#/components/schemas/FieldBase"+ }, {+ "required": [+ "title",+ "type"+ ]+ }]},"FieldOptions_LongText": {@@ -6516,6 +6527,9 @@},{"oneOf": [+ {+ "$ref": "#/components/schemas/FieldOptions/SingleLineText"+ },{"properties": {"type": {diff --git a/packages/nocodb/src/services/v3/columns-v3.service.ts b/packages/nocodb/src/services/v3/columns-v3.service.tsindex baf1484fc6..944a454633 100644--- a/packages/nocodb/src/services/v3/columns-v3.service.ts+++ b/packages/nocodb/src/services/v3/columns-v3.service.ts@@ -42,6 +42,10 @@ export class ColumnsV3Service {let column = await Column.get(context, { colId: param.columnId });+ if (!column) {+ NcError.get(context).fieldNotFound(param.columnId);+ }+const type = (param.column?.type ?? column.uidt) as FieldV3Type['type'];const processedColumnReq = columnV3ToV2Builder().build({diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/column.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/column.test.tsindex 131c1122d2..b2aa44f56a 100644--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/column.test.ts+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/column.test.ts@@ -39,6 +39,15 @@ export default function () {expect(result.body.error).to.eq('INVALID_REQUEST_BODY');expect(result.body.message).to.include('Invalid request body');});+ it('will handle no type', async () => {+ const result = await request(context.app)+ .post(`${API_PREFIX}/tables/${table.id}/fields/`)+ .set('xc-token', context.xc_token)+ .send({ title: 'MyColumn' })+ .expect(400);+ expect(result.body.error).to.eq('INVALID_REQUEST_BODY');+ expect(result.body.message).to.include('Invalid request body');+ });it('will handle duplicate alias', async () => {await request(context.app).post(`${API_PREFIX}/tables/${table.id}/fields/`)@@ -85,7 +94,7 @@ export default function () {});});- describe.only('column update', () => {+ describe('column update', () => {let column: any;beforeEach(async () => {const colResult = await request(context.app)@@ -95,13 +104,15 @@ export default function () {.expect(200);column = colResult.body;});- it.only('will handle column not found', async () => {++ it('will handle column not found', async () => {const result = await request(context.app).patch(`${API_PREFIX}/fields/NOT_FOUND`).set('xc-token', context.xc_token).send({ title: 'any' }).expect(400);- console.log(result.body)+ console.log(result)+expect(result.body.error).to.eq('FIELD_NOT_FOUND');expect(result.body.message).to.include(`Field 'NOT_FOUND' not found`);});