diff --git a/forward_engineering/services/statements/getPrimaryKeySampleByStructure.js b/forward_engineering/services/statements/getPrimaryKeySampleByStructure.js index 82f2de4..770f346 100644 --- a/forward_engineering/services/statements/getPrimaryKeySampleByStructure.js +++ b/forward_engineering/services/statements/getPrimaryKeySampleByStructure.js @@ -3,6 +3,7 @@ * @typedef {import('../../../shared/types').UUID} UUID */ const RandExp = require('randexp'); +const { isEmpty } = require('lodash'); const { PK_SEGMENT_TYPE } = require('../../../shared/constants'); /** @@ -10,7 +11,9 @@ const { PK_SEGMENT_TYPE } = require('../../../shared/constants'); * @returns {string} */ const getPrimaryKeySampleByStructure = ({ collection, jsonData }) => { - const keyField = Object.values(collection.properties || {}).find(field => field.primaryKeyStructure); + const keyField = Object.values(collection.properties || {}).find( + field => field.primaryKey && !isEmpty(field.primaryKeyStructure), + ); const primaryKeyStructure = keyField?.primaryKeyStructure; if (!Array.isArray(primaryKeyStructure)) { diff --git a/forward_engineering/services/statements/insertStatements.js b/forward_engineering/services/statements/insertStatements.js index d27de31..d24febf 100644 --- a/forward_engineering/services/statements/insertStatements.js +++ b/forward_engineering/services/statements/insertStatements.js @@ -32,7 +32,7 @@ const getInsertScriptForCollection = ({ jsonData, collection }) => { } const keyPropertyName = Object.keys(collection?.properties ?? {}).find(propertyName => - Boolean(collection?.properties?.[propertyName]['']), + Boolean(collection?.properties?.[propertyName]?.primaryKey), ); const insertionPath = getKeySpaceReference(collection); diff --git a/properties_pane/field_level/fieldLevelConfig.json b/properties_pane/field_level/fieldLevelConfig.json index 0a15f64..73600bd 100644 --- a/properties_pane/field_level/fieldLevelConfig.json +++ b/properties_pane/field_level/fieldLevelConfig.json @@ -224,7 +224,7 @@ making sure that you maintain a proper JSON format. } ], "dependency": { - "key": "containerLevelKey", + "key": "primaryKey", "value": true } },