Browse Source

fix: bridge table identification

Signed-off-by: mertmit <mertmit99@gmail.com>
feat/export-nest
mertmit 2 years ago
parent
commit
cea7055408
  1. 2
      packages/nocodb-nest/src/db/sql-client/lib/sqlite/SqliteClient.ts
  2. 6
      packages/nocodb-nest/src/helpers/populateMeta.ts
  3. 6
      packages/nocodb-nest/src/services/meta-diffs.service.ts

2
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

6
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();

6
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();

Loading…
Cancel
Save