From 2588992bdf0836355de81fc9b09240f66d6c72d2 Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Tue, 29 Sep 2020 18:52:25 -0400 Subject: [PATCH] Fix language code FK being generated as integer Fixes #441 --- .../routes/data-model/field-detail/store.ts | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/app/src/modules/settings/routes/data-model/field-detail/store.ts b/app/src/modules/settings/routes/data-model/field-detail/store.ts index 57c89298d9..d100a079cf 100644 --- a/app/src/modules/settings/routes/data-model/field-detail/store.ts +++ b/app/src/modules/settings/routes/data-model/field-detail/store.ts @@ -376,18 +376,33 @@ function initLocalStore( } if (fieldExists(junctionCollection, manyRelated) === false) { - state.newFields.push({ - $type: 'manyRelated', - collection: junctionCollection, - field: manyRelated, - type: collectionExists(relatedCollection) - ? fieldsStore.getPrimaryKeyFieldForCollection(relatedCollection)?.type - : 'integer', - schema: {}, - meta: { - hidden: true, - }, - }); + if (type === 'translations') { + state.newFields.push({ + $type: 'manyRelated', + collection: junctionCollection, + field: manyRelated, + type: collectionExists(relatedCollection) + ? fieldsStore.getPrimaryKeyFieldForCollection(relatedCollection)?.type + : 'string', + schema: {}, + meta: { + hidden: true, + }, + }); + } else { + state.newFields.push({ + $type: 'manyRelated', + collection: junctionCollection, + field: manyRelated, + type: collectionExists(relatedCollection) + ? fieldsStore.getPrimaryKeyFieldForCollection(relatedCollection)?.type + : 'integer', + schema: {}, + meta: { + hidden: true, + }, + }); + } } if (collectionExists(relatedCollection) === false) {