diff --git a/packages/nocodb-nest/src/db/sql-client/lib/sqlite/SqliteClient.ts b/packages/nocodb-nest/src/db/sql-client/lib/sqlite/SqliteClient.ts index db66cc0b47..830ed3aab1 100644 --- a/packages/nocodb-nest/src/db/sql-client/lib/sqlite/SqliteClient.ts +++ b/packages/nocodb-nest/src/db/sql-client/lib/sqlite/SqliteClient.ts @@ -409,7 +409,7 @@ class SqliteClient extends KnexClient { response[i].not_nullable = response[i].notnull === 1; response[i].rqd = response[i].notnull === 1; response[i].cdf = response[i].dflt_value; - response[i].pk = response[i].pk === 1; + response[i].pk = response[i].pk > 0; response[i].cop = response[i].cid; // https://stackoverflow.com/a/7906029 diff --git a/packages/nocodb-nest/src/helpers/populateMeta.ts b/packages/nocodb-nest/src/helpers/populateMeta.ts index 1ce90708e3..39ca7d1d2b 100644 --- a/packages/nocodb-nest/src/helpers/populateMeta.ts +++ b/packages/nocodb-nest/src/helpers/populateMeta.ts @@ -83,7 +83,11 @@ export async function extractAndGenerateManyToManyRelations( } // todo: impl better method to identify m2m relation - if (belongsToCols?.length === 2 && normalColumns.length < 5) { + if ( + belongsToCols?.length === 2 && + normalColumns.length < 5 && + assocModel.primaryKeys.length === 2 + ) { const modelA = await belongsToCols[0].colOptions.getRelatedTable(); const modelB = await belongsToCols[1].colOptions.getRelatedTable(); diff --git a/packages/nocodb-nest/src/services/meta-diffs.service.ts b/packages/nocodb-nest/src/services/meta-diffs.service.ts index 5891dc0901..75f21a2229 100644 --- a/packages/nocodb-nest/src/services/meta-diffs.service.ts +++ b/packages/nocodb-nest/src/services/meta-diffs.service.ts @@ -1014,7 +1014,11 @@ export class MetaDiffsService { } // todo: impl better method to identify m2m relation - if (belongsToCols?.length === 2 && normalColumns.length < 5) { + if ( + belongsToCols?.length === 2 && + normalColumns.length < 5 && + assocModel.primaryKeys.length === 2 + ) { const modelA = await belongsToCols[0].colOptions.getRelatedTable(); const modelB = await belongsToCols[1].colOptions.getRelatedTable();