Browse Source

fix: confirm fk and pk values match to detect m2m junction

pull/8371/head
mertmit 7 months ago
parent
commit
27558099c9
  1. 6
      packages/nocodb/src/helpers/populateMeta.ts

6
packages/nocodb/src/helpers/populateMeta.ts

@ -93,7 +93,11 @@ export async function extractAndGenerateManyToManyRelations(
if (
belongsToCols?.length === 2 &&
normalColumns.length < 5 &&
assocModel.primaryKeys.length === 2
assocModel.primaryKeys.length === 2 &&
// check if both belongsToCol target primary keys
assocModel.primaryKeys.every((pk) =>
belongsToCols.some((c) => c.colOptions?.fk_child_column_id === pk.id),
)
) {
const modelA = await belongsToCols[0].colOptions.getRelatedTable();
const modelB = await belongsToCols[1].colOptions.getRelatedTable();

Loading…
Cancel
Save