diff --git a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasNestedApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasNestedApis.ts index a7e25b587a..f084386d92 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasNestedApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasNestedApis.ts @@ -8,6 +8,7 @@ import { getColumnByIdOrName, getViewAndModelFromRequestByAliasOrId } from './he import { NcError } from '../../helpers/catchError'; import apiMetrics from '../../helpers/apiMetrics'; +// todo: handle case where the given column is not ltar export async function mmList(req: Request, res: Response, next) { const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); @@ -157,6 +158,7 @@ export async function btExcludedList(req: Request, res: Response, next) { ); } +// todo: handle case where the given column is not ltar export async function hmList(req: Request, res: Response, next) { const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); if (!model) return next(new Error('Table not found')); diff --git a/packages/nocodb/tests/unit/rest/tests/tableRow.test.ts b/packages/nocodb/tests/unit/rest/tests/tableRow.test.ts index 45f3d095f5..493e281e8c 100644 --- a/packages/nocodb/tests/unit/rest/tests/tableRow.test.ts +++ b/packages/nocodb/tests/unit/rest/tests/tableRow.test.ts @@ -1574,6 +1574,24 @@ function tableTest() { } }) + it('Create hm relation with non ltar column', async () => { + const rowId = 1; + const firstNameColumn = (await customerTable.getColumns()).find( + (column) => column.title === 'FirstName' + )!; + const refId = 1; + const response = await request(context.app) + .post(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/${rowId}/hm/${firstNameColumn.id}/${refId}`) + .set('xc-auth', context.token) + .expect(404); + global.touchedSakilaDb = true; + + if(response.body['msg'] !== 'Column not found' ) { + console.log(response.body) + throw new Error('Wrong error message'); + } + }) + it('Create list hm wrong column id', async () => { const rowId = 1; const refId = 1; @@ -1655,6 +1673,26 @@ function tableTest() { } }) + + it('Create mm relation with non ltar column', async () => { + const rowId = 1; + const actorTable = await getTable({project: sakilaProject, name: 'actor'}); + const firstNameColumn = (await actorTable.getColumns()).find( + (column) => column.title === 'FirstName' + )!; + const refId = 1; + const response = await request(context.app) + .post(`/api/v1/db/data/noco/${sakilaProject.id}/${actorTable.id}/${rowId}/mm/${firstNameColumn.id}/${refId}`) + .set('xc-auth', context.token) + .expect(404); + global.touchedSakilaDb = true; + + if(response.body['msg'] !== 'Column not found' ) { + console.log(response.body) + throw new Error('Wrong error message'); + } + }) + it('Create list mm existing ref row id', async () => { const rowId = 1; const actorTable = await getTable({project: sakilaProject, name: 'actor'}); @@ -1698,6 +1736,30 @@ function tableTest() { throw new Error('Wrong list length'); } }) + + it('List hm with non ltar column', async () => { + const rowId = 1; + const firstNameColumn = (await customerTable.getColumns()).find( + (column) => column.title === 'FirstName' + )!; + + await request(context.app) + .get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/${rowId}/hm/${firstNameColumn.id}`) + .set('xc-auth', context.token) + .expect(400) + }) + + it('List mm with non ltar column', async () => { + const rowId = 1; + const firstNameColumn = (await customerTable.getColumns()).find( + (column) => column.title === 'FirstName' + )!; + + await request(context.app) + .get(`/api/v1/db/data/noco/${sakilaProject.id}/${customerTable.id}/${rowId}/mm/${firstNameColumn.id}`) + .set('xc-auth', context.token) + .expect(400) + }) } export default function () {